Basic removal
Input
[1, 2, 3, 4, 5], 2
Output
[1, 2, 3, 5]
The 2nd node from the end is 4. Removing it yields [1,2,3,5].
Full lesson preview
Remove the nth node from the end of a singly linked list using the two-pointer technique (fast & slow).
Problem statement
Task
Examples
Input
[1, 2, 3, 4, 5], 2
Output
[1, 2, 3, 5]
The 2nd node from the end is 4. Removing it yields [1,2,3,5].
Input format
Output format
Constraints
Samples
Input
[1,2,3,4,5], 2
Output
[1,2,3,5]
Remove the 2nd from end (4).