File tree Expand file tree Collapse file tree 12 files changed +128
-3
lines changed 
s0019_remove_nth_node_from_end_of_list 
s0021_merge_two_sorted_lists 
s0023_merge_k_sorted_lists 
s0024_swap_nodes_in_pairs 
s0025_reverse_nodes_in_k_group 
g0101_0200/s0160_intersection_of_two_linked_lists 
s0206_reverse_linked_list 
s0234_palindrome_linked_list 
g0301_0400/s0382_linked_list_random_node 
g1101_1200/s1171_remove_zero_sum_consecutive_nodes_from_linked_list 
g1201_1300/s1290_convert_binary_number_in_a_linked_list_to_integer Expand file tree Collapse file tree 12 files changed +128
-3
lines changed Original file line number Diff line number Diff line change 55
66import  com_github_leetcode .ListNode ;
77
8+ /* 
9+  * Definition for singly-linked list. 
10+  * public class ListNode { 
11+  * int val; 
12+  * ListNode next; 
13+  * ListNode() {} 
14+  * ListNode(int val) { this.val = val; } 
15+  * ListNode(int val, ListNode next) { this.val = val; this.next = next; } 
16+  * } 
17+  */ 
818public  class  Solution  {
9-  int  n ;
19+  private   int  n ;
1020
1121 public  ListNode  removeNthFromEnd (ListNode  head , int  n ) {
1222 this .n  = n ;
1323 ListNode  node  = new  ListNode (0 , head );
1424 removeNth (node );
15- 
1625 return  node .next ;
1726 }
1827
1928 private  void  removeNth (ListNode  node ) {
2029 if  (node .next  == null ) {
2130 return ;
2231 }
23- 
2432 removeNth (node .next );
2533 this .n --;
2634
Original file line number Diff line number Diff line change 66
77import  com_github_leetcode .ListNode ;
88
9+ /* 
10+  * Definition for singly-linked list. 
11+  * public class ListNode { 
12+  * int val; 
13+  * ListNode next; 
14+  * ListNode() {} 
15+  * ListNode(int val) { this.val = val; } 
16+  * ListNode(int val, ListNode next) { this.val = val; this.next = next; } 
17+  * } 
18+  */ 
919public  class  Solution  {
1020 public  ListNode  mergeTwoLists (ListNode  l1 , ListNode  l2 ) {
1121 ListNode  list  = new  ListNode (-1 );
Original file line number Diff line number Diff line change 55
66import  com_github_leetcode .ListNode ;
77
8+ /* 
9+  * Definition for singly-linked list. 
10+  * public class ListNode { 
11+  * int val; 
12+  * ListNode next; 
13+  * ListNode() {} 
14+  * ListNode(int val) { this.val = val; } 
15+  * ListNode(int val, ListNode next) { this.val = val; this.next = next; } 
16+  * } 
17+  */ 
818public  class  Solution  {
919 public  ListNode  mergeKLists (ListNode [] lists ) {
1020 if  (lists .length  == 0 ) {
Original file line number Diff line number Diff line change 55
66import  com_github_leetcode .ListNode ;
77
8+ /* 
9+  * Definition for singly-linked list. 
10+  * public class ListNode { 
11+  * int val; 
12+  * ListNode next; 
13+  * ListNode() {} 
14+  * ListNode(int val) { this.val = val; } 
15+  * ListNode(int val, ListNode next) { this.val = val; this.next = next; } 
16+  * } 
17+  */ 
818public  class  Solution  {
919 public  ListNode  swapPairs (ListNode  head ) {
1020 if  (head  == null ) {
Original file line number Diff line number Diff line change 55
66import  com_github_leetcode .ListNode ;
77
8+ /* 
9+  * Definition for singly-linked list. 
10+  * public class ListNode { 
11+  * int val; 
12+  * ListNode next; 
13+  * ListNode() {} 
14+  * ListNode(int val) { this.val = val; } 
15+  * ListNode(int val, ListNode next) { this.val = val; this.next = next; } 
16+  * } 
17+  */ 
818public  class  Solution  {
919 public  ListNode  reverseKGroup (ListNode  head , int  k ) {
1020 if  (head  == null  || head .next  == null  || k  == 1 ) {
Original file line number Diff line number Diff line change 55
66import  com_github_leetcode .ListNode ;
77
8+ /* 
9+  * Definition for singly-linked list. 
10+  * public class ListNode { 
11+  * int val; 
12+  * ListNode next; 
13+  * ListNode() {} 
14+  * ListNode(int val) { this.val = val; } 
15+  * ListNode(int val, ListNode next) { this.val = val; this.next = next; } 
16+  * } 
17+  */ 
818public  class  Solution  {
919 public  ListNode  rotateRight (ListNode  head , int  k ) {
1020 if  (head  == null  || k  == 0 ) {
Original file line number Diff line number Diff line change 55
66import  com_github_leetcode .ListNode ;
77
8+ /* 
9+  * Definition for singly-linked list. 
10+  * public class ListNode { 
11+  * int val; 
12+  * ListNode next; 
13+  * ListNode(int x) { 
14+  * val = x; 
15+  * next = null; 
16+  * } 
17+  * } 
18+  */ 
819@ SuppressWarnings ("java:S2583" )
920public  class  Solution  {
1021 public  ListNode  getIntersectionNode (ListNode  headA , ListNode  headB ) {
Original file line number Diff line number Diff line change 66
77import  com_github_leetcode .ListNode ;
88
9+ /* 
10+  * Definition for singly-linked list. 
11+  * public class ListNode { 
12+  * int val; 
13+  * ListNode next; 
14+  * ListNode() {} 
15+  * ListNode(int val) { this.val = val; } 
16+  * ListNode(int val, ListNode next) { this.val = val; this.next = next; } 
17+  * } 
18+  */ 
919public  class  Solution  {
1020 public  ListNode  reverseList (ListNode  head ) {
1121 ListNode  prev  = null ;
Original file line number Diff line number Diff line change 55
66import  com_github_leetcode .ListNode ;
77
8+ /* 
9+  * Definition for singly-linked list. 
10+  * public class ListNode { 
11+  * int val; 
12+  * ListNode next; 
13+  * ListNode() {} 
14+  * ListNode(int val) { this.val = val; } 
15+  * ListNode(int val, ListNode next) { this.val = val; this.next = next; } 
16+  * } 
17+  */ 
818public  class  Solution  {
919 public  boolean  isPalindrome (ListNode  head ) {
1020 int  len  = 0 ;
Original file line number Diff line number Diff line change 88import  java .util .List ;
99import  java .util .Random ;
1010
11+ /* 
12+  * Definition for singly-linked list. 
13+  * public class ListNode { 
14+  * int val; 
15+  * ListNode next; 
16+  * ListNode() {} 
17+  * ListNode(int val) { this.val = val; } 
18+  * ListNode(int val, ListNode next) { this.val = val; this.next = next; } 
19+  * } 
20+  */ 
1121@ SuppressWarnings ("java:S2245" )
1222public  class  Solution  {
1323 private  List <Integer > al ;
@@ -33,3 +43,9 @@ public int getRandom() {
3343 return  al .get (ind );
3444 }
3545}
46+ 
47+ /* 
48+  * Your Solution object will be instantiated and called as such: 
49+  * Solution obj = new Solution(head); 
50+  * int param_1 = obj.getRandom(); 
51+  */ 
                         You can’t perform that action at this time. 
           
                  
0 commit comments