Approach Summary
Check if k nodes remain. If so, reverse them, then recursively process the rest and attach. If fewer than k remain, leave as-is.
How to Recognize This Pattern
- "Reverse every k nodes"
- Verify k nodes exist before reversing — leave tail as-is
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(1)
Tags
Linked List Recursion