Back to DSA
Remove Nth Node From End of List
mediumGiven a linked list and an integer n, delete the node that is n positions from the end of the list and return the modified list's head. Aim for a single-pass solution.
Examples
Example 1:
Input:
head = [10,20,30,40,50], n = 3Output:
[10,20,40,50] Example 2:
Input:
head = [7], n = 1Output:
[]Hints
1234567