15% off all plans & roadmaps Use code
See plansLeetCode 61 · Solution & editorial
Given the head of a linked list, rotate the list to the right by k places.
Rotate List is a Linked List Manipulation Patterns problem, in the Reordering / Partitioning subpattern. The pattern covers in-place reversal, merging sorted lists, reordering, and intersection detection
Learn to reorder and partition linked lists. Master techniques like swap pairs, rotate list, and odd-even separation.
The reference solution runs in O(n) time and O(1) space.
Rotate List has been reported in interviews at Amazon, Bloomberg, Microsoft, Apple.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Rotate List is a Linked List Manipulation Patterns problem, in the Reordering / Partitioning subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.