Reverse Linked List II Visualizer & Solution | Rulcode
Loading problem details...
188. Reverse Linked List II
Medium
Topics
Companies
Hint
Understand Before Coding
Visualize This Problem
Open Visualizer
Draw Your Approach
Draw
Example 1:
Input:head = [1,2,3,4,5], left = 2, right = 4
Output:[1,4,3,2,5]
Explanation:The sublist from position 2 (value 2) to position 4 (value 4) is [2,3,4]. Reversing this segment yields [4,3,2]. The list becomes 1 -> 4 -> 3 -> 2 -> 5.
Example 2:
Input:head = [5], left = 1, right = 1
Output:[5]
Explanation:The sublist from position 1 (value 5) to position 1 (value 5) is [5]. Reversing a single-node list results in the same list. The list remains [5].