LeetCode 3Sum: Sort + Two Pointers Step by Step
A careful walkthrough of LeetCode 15 3Sum using sort plus two pointers. We handle duplicate triplets cleanly and avoid the classic off-by-one traps.
·6 min read · #dsa#leetcode#two-pointers
4 posts.
A careful walkthrough of LeetCode 15 3Sum using sort plus two pointers. We handle duplicate triplets cleanly and avoid the classic off-by-one traps.
Solve LeetCode 11 Container With Most Water with the two-pointer technique. We prove correctness and contrast it with the quadratic brute force.
Solve LeetCode 42 Trapping Rain Water in linear time and constant space using the two-pointer technique. Brute force, optimal walkthrough, and interview talk track.
A practical guide to the two pointers technique — opposite-end and same-direction patterns, when to use each, and six classic interview problems with worked solutions.