Skip to content

Commit c6a91a9

Browse files
add solution 019[js]
1 parent 224f3c8 commit c6a91a9

File tree

1 file changed

+13
-0
lines changed
  • solution/019.Remove Nth Node From End of List

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const removeNthFromEnd = function(head, n){
2+
let left, before, right = head;
3+
left = before = {next: head};
4+
while(n--){
5+
right = right.next;
6+
}
7+
while(right){
8+
right =right.next;
9+
left = left.next;
10+
}
11+
left.next = left.next.next;
12+
return before.next;
13+
}

0 commit comments

Comments
 (0)