19. Remove Nth Node From End of List
MediumLinked List
Given the head of a linked list, remove the nth node from the end of the list and return its head.
Examples
Input: [1,2,3,4,5] 2
Output: [1,2,3,5]
Explanation: The 2nd node from the end is 4; removing it yields 1->2->3->5.
Constraints
- The number of nodes in the list is sz.
- 1 <= sz <= 30
- 0 <= Node.val <= 100
- 1 <= n <= sz
Loading...
Run checks all cases above. Submit evaluates all test cases.