905. Deletion of the Kth element of Linked List
Given the head of a singly linked list and an integer k, delete the kth node of the linked list and return the head of the modified list.
Example 1:
Input: linkedList = [3, 4, 5], k = 2
Output: linkedList = [3, 5]
Explanation:
The 2nd node with value 4 was removed.
Example 2:
Input: linkedList = [1, 2, 3], k = 1
Output: [2, 3]
Explanation:
The 1st Node was removed, note that the value of the head has changed.
Now Your Turn!
Pick the correct output for the given inputInput: linkedList = [7, 7, 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 <= 1000
- 0 <= ListNode.val <= 100
- 1 <= k <= n