Dashboard
LC #92
Reverse Linked List II
Pattern · ?MetaAmazonMicrosoft
Problem
Reverse the nodes of the list from position left to right in one pass.
Constraints
- 1 ≤ n ≤ 500
- -500 ≤ Node.val ≤ 500
- 1 ≤ left ≤ right ≤ n
- Must be done in one pass
Example
- Input
- head = [1, 2, 3, 4, 5], left = 2, right = 4
- Output
- [1, 4, 3, 2, 5]
- Why
- Nodes at positions 2–4 (1-indexed) are reversed in one pass
Spot the pattern
Which pattern cracks it?
Hints
One at a time