718. Remove Kth Node from End of Linked List

0

Medium

Given the head of a linked list, remove the Kth node from the end of the list and display the updated linked list.

Input Format

The first line of input contains the size N of the linked list and the value of K.
The second line of input contains the nodes of the linked list.

Output Format

Display the linked list after removing the Kth node from the end.

Example

Input

4 2 1 2 3 4

Output

1 2 4

Constraints

The linked list contains N nodes.
1 <= N <= 30
Each node's value is between 0 and 100.
1 <= K <= N
Loading...

View Submissions

Console