We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 13490c5 commit 6de37b3Copy full SHA for 6de37b3
doc/cheatsheet/linked_list.md
@@ -289,6 +289,34 @@ class LinkedList:
289
290
### 1-1) Basic OP
291
292
+
293
+#### 1-1-0) Remove Nth node from end
294
+```java
295
+// java
296
+// LC 19
297
298
+// ...
299
+ListNode dummy = new ListNode(0);
300
+dummy.next = head;
301
+ListNode fast = dummy;
302
+ListNode slow = dummy;
303
304
+for (int i = 1; i <= n+1; i++){
305
+ //System.out.println("i = " + i);
306
+ fast = fast.next;
307
+}
308
309
+// move fast and slow pointers on the same time
310
+while (fast != null){
311
312
+ slow = slow.next;
313
314
315
+// NOTE here
316
+slow.next = slow.next.next;
317
318
+```
319
320
#### 1-1-1) transversal linked list
321
322
#### 1-1-2) plus one on linked list
0 commit comments