Learn › DSA Patterns
DSA Patterns
The handful of algorithmic patterns that show up again and again in coding interviews — each with a story, a visualizer, working TypeScript, and practice questions.
Patterns
Pick a Pattern
Two Pointers
Converge two pointers from opposite ends of an array or string to solve palindrome, pair-sum, and comparison problems in O(N) time, O(1) space.
O(N) time · O(1) spaceSliding Window
Maintain a running window over arrays or strings to turn O(N²) brute force into O(N) for subarray and substring problems.
O(N) time · O(1)–O(K) spaceFast and Slow Pointers
Floyd's Tortoise and Hare — two pointers moving at different speeds through a linked list to detect cycles in O(N) time, O(1) space.
O(N) time · O(1) spaceTop K Elements
Use a min-heap of size K to find the K largest, most frequent, or closest elements without fully sorting the input.
O(N log K) time · O(K) spaceWorked Examples
Case Studies
Real debugging journeys on real LeetCode problems — not just the final answer.
Case Study: Valid Palindrome (LeetCode 125)
A real attempt-by-attempt debugging journey — five bugs found and fixed on the way to a clean Two Pointers solution.
Case Study: 3Sum (LeetCode 15)
A real attempt-by-attempt debugging journey — four bugs found and fixed on the way to a clean Two Pointers solution.
Case Study: Longest Substring Without Repeating Characters (LeetCode 3)
A real attempt-by-attempt debugging journey — six bugs found and fixed on the way to a clean Sliding Window solution.
More Learning Resources
Explore the full Learn library for SEO, marketing, and business growth guides.
← Back to Learn