Learn โ€บ DSA Patterns

DSA Patterns

The handful of algorithm patterns that keep showing up in coding interviews. Each one has a walkthrough, a visualizer, working TypeScript, and problems to practice on.

Worked Examples

Case Studies

The wrong turns on real LeetCode problems, not just the answer that worked.

๐Ÿงช

Case Study: Valid Palindrome (LeetCode 125)

Five bugs, caught one at a time, before the Two Pointers version finally passed. Every wrong turn is here too.

๐ŸŽฏ

Case Study: 3Sum (LeetCode 15)

The duplicate-skipping logic is where this one bites. Four attempts, four bugs, then a clean Two Pointers solution.

๐ŸชŸ

Case Study: Longest Substring Without Repeating Characters (LeetCode 3)

Six bugs, mostly around when to shrink the window and how to move the left pointer. The full trail to a working Sliding Window.

๐Ÿ”

Case Study: Longest Repeating Character Replacement (LeetCode 424)

The trick is knowing you never have to shrink the window. Six bugs before that clicked, all written up.

๐Ÿ”—

Case Study: Remove Nth Node From End of List (LeetCode 19)

Four attempts to get the gap between the two pointers right, and why the dummy node saves you from the edge cases.

๐ŸŒ€

Case Study: Linked List Cycle (LeetCode 141)

A short one. Two bugs, both about null checks on the fast pointer, then Floyd's Cycle Detection works.

๐Ÿ” 

Case Study: Substrings of Size Three With Distinct Characters (LeetCode 1876)

Not a debugging story so much as a trimming one: from an over-built first pass to a fixed-size window that allocates nothing.

๐Ÿ”„

Case Study: Reverse Linked List (LeetCode 206)

Four attempts at the order you reassign prev, curr, and temp. Get it wrong and you drop half the list.

๐ŸŽฏ

Case Study: Find First and Last Position of Element in Sorted Array (LeetCode 34)

Six bugs, nearly all of them off-by-one, on the way to a two-pass binary search that finds both boundaries.

More in Learn

The rest of the Learn library covers SEO, marketing, system design, and finance.

โ† Back to Learn