Skip to content
New
Loading problem
Remove Nth Node From End · medium linked list interview problem · Larpy
LarpCode 150
medium
· linked-list
Mock interview
Remove Nth Node From End
Given the head of a singly linked list, remove the n-th node from the end and return the head.
Figure
node by position
1
0
2
1
3
2
4
3
5
4
null
Examples
in: head = [1,2,3,4,5], n = 2
out: [1,2,3,5]
the node with value 4 is removed
Constraints
1 <= number of nodes <= 30
1 <= n <= number of nodes
Hints
Stuck? Show a hint (2 available)
Python
JavaScript
Java
C++
Go
Run
Submit
target: O(n) time, one pass
⌘↩ run · ⇧⌘↩ submit
see the solution
More linked-list problems
Reverse a Linked List
easy
Merge Two Sorted Lists
easy
Palindrome Linked List
easy
Merge k Sorted Lists
hard
Reverse Nodes in k-Group
hard
Add Two Numbers
medium