Reverse Nodes in k-Group
hardReverse the nodes of a linked list k at a time and return the modified list
Reverse Nodes in K-Group
Key Insight
Count k nodes ahead, reverse that segment, connect to the result of the next group
Step 1Setup
k = 3Group 1: [1,2,3]Remaining: [4,5]
1
2
3
4
5
null
List [1,2,3,4,5] with k=3. Reverse groups of 3.
1 / 6