Algorithm Visualizer
Step through two pointers, sliding window, binary search, BFS/DFS, heaps, DP, and union-find one operation at a time.
Algorithm visualizer
Step through the core interview patterns one operation at a time — pointers, windows, queues, heaps, DP tables, and disjoint sets — with the pseudo-code line highlighted as it runs. Edit the input to test your own edge cases. Free for everyone.
Two Pointers: Pair Sum
Walk inward from both ends of a sorted array, discarding a whole row of pairs with every move.
Two PointersO(n) time · O(1) spaceSliding Window: Longest Unique Substring
Grow the window on the right, shrink it on the left the moment a character repeats.
Sliding WindowO(n) time · O(k) spaceBinary Search
Halve the search range every step by comparing the target with the middle element.
Binary Search on ArraysO(log n) time · O(1) spaceBFS vs DFS on a Grid
Same loop, different container: a queue explores in rings (shortest path), a stack dives deep.
BFS & DFS PatternsO(rows × cols) time and spaceMin-Heap: Push & Pop
Watch sift-up and sift-down keep the minimum at the root, in both array and tree form.
Heaps & Top-KO(log n) per push/pop · O(1) peekDP Table: Longest Common Subsequence
Fill a 2-D table cell by cell from smaller subproblems, then walk back to read the answer.
2-D Dynamic ProgrammingO(m·n) time · O(m·n) spaceUnion-Find with Path Compression
Merge components by rank and flatten find paths so connectivity queries become nearly O(1).
Union-Find (Disjoint Set)≈ O(α(n)) per operation