All Patterns
🔗
mediumPattern #12
Linked List In-Place
Reverse, merge, or restructure linked lists without extra space.
What is this pattern?
Linked list problems require careful pointer manipulation. The key operations — reverse, merge, find middle, detect cycle — each have a standard pointer pattern. Most hard problems combine two or three of these primitives.
When to use it
- Reversing all or part of a linked list
- Merging two sorted lists or K sorted lists
- Rearranging nodes (odd-even, rotate, reorder)
- Deep copying a list with random pointers
Key Insight
Always draw 3-4 nodes on paper and trace pointer changes before coding. Keep a 'prev' pointer when reversing. Use a dummy head node to handle edge cases at the start of the list cleanly.
Pro Content
The Java template and practice problems for this pattern are part of the Pro plan. Upgrade to unlock all patterns, 500+ problems, and Aria code reviews.
From ₹3,999 for a year · one-time, no auto-renewal