Loading your interview setup
Skip to content
New
Loading
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.
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