Remove Nth Node From End of List
Medium
Topics
Given the head of a linked list, remove the k-th node from the end and return the head. (LeetCode calls this parameter n.)
Example 1
Input: head = [1,2,3,4,5], k = 2 Output: [1,2,3,5]
Example 2
Input: head = [1], k = 1 Output: []
Constraints
- 1 <= number of nodes <= 30
- 1 <= k <= number of nodes
Run ⌘' · Submit ⌘⏎