You now understand both approaches. The iterative three-pointer technique is more space-efficient. The recursive approach is cleaner to write but uses stack space.
For interviews, know both. Start with iterative unless the problem particularly asks for recursion.
Common bugs:
- Forgetting to save
nextbefore overwritingcurrent.next - Returning
currentinstead ofprev(current is null at the end) - Not handling empty list or single-node list
Test your solution on: empty list, single node, two nodes, longer lists. Time: . Space: .