888. Delete Kth Element of Doubly Linked List
Given the head of a doubly linked list and an integer k, remove the node at the kth position of the linked list and return the head of the modified list.
Example 1:
Input: head = [2, 5, 7, 9], k = 2
Output: head = [2, 7, 9]
Explanation:
- The node with value 5 was removed.
Example 2:
Input: head = [2, 5, 7], k = 1
Output: head = [5, 7]
Explanation:
The node with value 2 was removed, note that the head was modified.
Now Your Turn!
Pick the correct output for the given inputInput: head = [2, 5, 7], k = 3
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- n == Number of nodes in the linked list
- 1 <= n <= 100
- 0 <= ListNode.val <= 100
- 1 <= k <= n