
3Sum: Fix One Element, Reduce to Two Sum with Two Pointers
Learn why 3Sum reduces to sorted Two Sum. Interactive visualizer shows how fixing one element and using two pointers drops O(n³) to O(n²).
Loading...
Crack the code, ace the interview
10 posts

Learn why 3Sum reduces to sorted Two Sum. Interactive visualizer shows how fixing one element and using two pointers drops O(n³) to O(n²).

Learn why water at each bar depends on its tallest neighbors. Interactive visualizer shows how two pointers find trapped water in one pass.

Learn why the shorter wall limits everything. Interactive visualizer shows how two pointers eliminate entire rows of possibilities in one pass.

See why Next Permutation is about finding the rightmost ascent. Interactive visualizer shows how one scan from the right transforms O(n!) brute force into O(n).

See why Two Sum is just an existence check. Interactive visualizer shows how one equation turns O(n²) brute force into O(n) with hash maps.

Visualize why O(log n) feels like magic. Watch binary search rip through a phonebook while linear search flips page by page.

Watch BFS spread like a sound wave while DFS dives like a snake. Interactive visual included.

Visualize why naive recursion explodes exponentially. Watch memoization turn chaos into order with an interactive Fibonacci simulator.

Visualize why O(n²) is inefficient through a heat map simulator. Watch brute force burn CPU cycles while sliding window glides smoothly.
Visualize backtracking through an interactive lock picker simulator. Watch how state reversibility saves memory while brute force creates infinite universes.