题目描述
Given a singly linked list and an integer x.Delete x^{th} node from the singly linked list.
Example 1:
Input: 1 -> 3 -> 4
x = 3
Output: 1 -> 3
Explanation:
After deleting the node at 3rd
position (1-base indexing), the
linked list is as 1 -> 3.
Example 2:
Input: 1 -> 5 -> 2 -> 9
x = 2
Output: 1 -> 2 -> 9
Explanation:
After deleting the node at 2nd
position (1-based indexing), the
linked list is as 1 -> 2 -> 9.
Your task: Your task is to complete the method deleteNode() which takes two arguments: the address of the head of the linked list and an integer x. The function returns the head of the modified linked list.
Constraints:
1 <= T <= 300
2 <= N <= 100
1 <= x <= N
输入格式
见题面
输出格式
见题面
样例输入
1 -> 3 -> 4
x = 3
样例输出
1 -> 3