Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Rotate List

XPChallenge Points: 20
levelLevel: Medium

You are given the head of a singly linked list and an integer k.
Rotate the list to the right by k positions — meaning each node is moved k steps forward, and the nodes that go beyond the end reappear at the start.

Example 1:

Input: head = [1,2,3], k = 1

Output: [3,1,2]

Example 2:

Input: head = [10,20,30,40,50], k = 3

Output: [30,40,50,10,20]

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result