51. Remove Nth Node From End of List

Given a singly linked list head and an integer n. Remove the n-th node from the end of the list and return the head of the modified list.
Example 1
Input: head = [1], n = 1
Output: []
Explanation: The only node in the list is removed.
Example 2
Input: head = [1,2,3,4,5], n = 2
Output: [1,2,3,5]
Explanation: The second node from the end is 4; it is removed.
linked listmedium
JavaScript
Loading...
Line 1, Char 1