Linked List + Recursion
Use recursion for reversal, merge, sorted insert operations.
linked-listrecursionUpdated 2025-09-01
Tradeoff
- Simpler code vs O(n) stack
Example
- ListNode rev(ListNode h){ if(!h||!h.next) return h; ListNode r=rev(h.next); h.next.next=h; h.next=null; return r; }