15% off all plans & roadmaps Use code
See plansLeetCode 92 · Solution & editorial
Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list.
Reverse Linked List II is a Linked List Manipulation Patterns problem, in the In-place Reversal subpattern. The pattern covers in-place reversal, merging sorted lists, reordering, and intersection detection
Master in-place linked list reversal including full reversal, partial reversal, and k-group reversal techniques.
The reference solution runs in O(n) time and O(n) space.
Reverse Linked List II has been reported in interviews at Amazon, Facebook, Microsoft, Oracle, ByteDance.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Reverse Linked List II is a Linked List Manipulation Patterns problem, in the In-place Reversal subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.