538. Node removal from LL

0

Easy

Given the head of a linked list, remove the nth node from the end of the list and return its head.

Input Format

Int n number of nodes in a linked list and int x pos from the end
n numbers which are the values of n nodes

Output Format

Print the updated list or just return the updated head

Example

Input

6 2 1 2 3 4 5 6

Output

1 2 3 4 6

Constraints

The number of nodes in the list is sz.
1 <= sz <= 30000
0 <= Node.val <= 100000
1 <= x <= sz
If there is no node in the linked list then just print -1
Loading...

View Submissions

Console