Insert Node at Given Position
Insert a new node at a given position in a singly linked list.
Input format
The first line contains N, POS (0 ≤ POS ≤ N), and VAL. The second line contains the N node values.
Output format
Insert a node with value VAL at 0-based position POS and print the resulting list.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
4 2 99
1 2 3 4Expected output
1 2 99 3 4Example 2
Input
1 0 5
7Expected output
5 7