Coding

Rotate a linked list to the right by k places.

Given the head of a linked list, rotate the list to the right by k places.

Input: head = [0,1,2], k = 4

Output: [2,0,1]

Explanation: The list has a length of 3. Rotating by 4 is mathematically equivalent to rotating by 1 (4 mod 3 = 1).

Was asked at

Practice this question with AI

First session is free - no credit card required.

Go Premium

More interviews, more skills, more success.

No answers yet

Be the first to share your approach to this question

Practice More Questions