Rotate Linked List Problem

Rotate Linked List Problem — ExecCode Easy DSA Practice

Solve the Rotate Linked List problem on ExecCode. Free online easy DSA practice in Linked List. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given the head of a linked list, rotate the list to the right by k places.

Examples

Input {"values": [1, 2, 3, 4, 5], "k": 2}; Output 4 5 1 2 3. Input {"values": [0, 1, 2], "k": 4}; Output 2 0 1. Input {"values": [1, 2], "k": 1}; Output 2 1

Constraints

The number of nodes in the list is in the range [0, 500]. -100 <= Node.val <= 100 0 <= k <= 2 * 10^9

Practice Rotate Linked List free on ExecCode. Browse DSA problems, topic map, and placement guides.