Skip to content

Commit 2b827f2

Browse files
authored
Create InvertBinaryTree.java
1 parent 1a250b7 commit 2b827f2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

InvertBinaryTree.java

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* public class ListNode {
4+
* int val;
5+
* ListNode next;
6+
* ListNode(int x) { val = x; }
7+
* }
8+
*/
9+
class Solution {
10+
public void deleteNode(ListNode node) {
11+
// here we have access of only the node which is to be deleted
12+
//so we will copy the value of next node in given node and we will delete next node;
13+
//copying next node value;
14+
node.val=node.next.val;
15+
//deleting next node;
16+
node.next=node.next.next;
17+
18+
}
19+
}

0 commit comments

Comments
 (0)