Skip to content
C

Rotate Linked List

Mediumjavapythonccppjavascript

Given a linked list and an integer K, move the last K nodes to the beginning of the list.

Input Format

The first line contains two integers N and K. The second line contains N space-separated integers.

Output Format

Print the rotated list from head to tail, separated by single spaces.

Input (stdin)

Output

Run your code to see output here...