Tags

Patterns

Patterns

7 lessons
10 community items

patterns

Foundations

1 lesson

Time Complexity Analysis Techniques

Free
Beginner

50 min

1 prereq

Recognizing `O(n)` or `O(n^2)` on a slide is one thing; staring at unfamiliar code in an interview and confidently announcing its complexity is another. The gap between those two skills is filled by analysis technique, and that technique is what this lesson hands you. **Time Complexity Analysis Techniques** turns Big-O classification into a repeatable workflow you can apply to any snippet. You will analyze single loops with non-standard step sizes, nested loops where the inner bounds depend on the outer variable, sequential blocks that you sum and simplify, `if`/`else` branches where you take the worst case, and the telltale halving-or-multiplying patterns that produce `O(log n)`. Along the way you will see why a triangular loop summing `0 + 1 + 2 + ... + (n-1)` lands at `O(n^2)`, and why constant-bounded loops collapse to `O(1)` no matter how many times they run. In **Big-O Notation (Upper Bound)**, you learned what `O(f(n))` means and how to spot the dominant term in a polynomial. This lesson sharpens that recognition into a procedure: count iterations precisely, multiply for nesting, add for sequencing, and drop everything but the dominant term. Once you can dissect time complexity from real code, you will be ready for **Space Complexity Fundamentals**, where you apply the same Big-O lens to memory usage instead of operation counts.

Not Started

0%

Foundations
Beginner
Free
Time Complexity
Big-O
Analysis Techniques
Efficiency
Patterns

Algorithms

6 lessons

Binary Search Templates

Intermediate

55 min

1 prereq

Standard binary search returns an arbitrary index of a target if duplicates exist, but real problems usually want the _first_ such index, the _last_ such index, or the smallest capacity that ships every package within `D` days. Each variation needs a slightly different loop condition and return value, and getting one wrong produces an off-by-one bug or an infinite loop. **Binary Search Templates** turns those variations into a small set of memorable templates. You will work through first and last occurrence with `<=` versus `<` loop conditions, lower bound and upper bound (the templates behind Python's `bisect_left` and `bisect_right`), binary search on the answer space (the "minimize the maximum" pattern that solves Koko Eating Bananas, Capacity to Ship Packages, and Split Array Largest Sum), and search in rotated sorted arrays where the invariant holds for exactly one half at each step. In **Binary Search (Intro)**, you wrote the canonical exact-match loop and learned why it is `O(log n)`. This lesson keeps the halving idea but switches the question from "is `target` here?" to "what is the smallest index that satisfies a monotonic predicate?". Next, **Linked List Algorithms** turns to pointer manipulation patterns.

Not Started

0%

Algorithms
Binary Search
Binary Search Templates
Searching
Patterns
Problem Solving
Intermediate
Premium

Hashing Techniques

Free
Beginner

45 min

1 prereq

Two Sum was a hard problem in 2010. With a hash map it becomes a six-line interview warm-up: walk the array once, and for each value `x` ask whether `target - x` is already in the map. The same shape, single-pass plus complement lookup, solves "first duplicate," "contains nearby duplicate," "longest substring without repeats," and an entire family of trade-space-for-time problems. **Hashing Techniques** catalogs those patterns. You will work through frequency counting (most/least frequent element, group anagrams via sorted-key trick), the two-sum complement template and its three-sum / four-sum extensions, existence checking and duplicate detection, index mapping where you store positions alongside values, and a first conceptual look at rolling hashes that prepare you for Rabin-Karp later. The lesson also discusses when a hash map is overkill versus when it is the obviously correct tool. In **Hash Map (Dictionary) Basics**, you saw how hashing achieves expected `O(1)` insertion and lookup. This lesson is where that constant-time primitive turns into algorithmic leverage: brute-force `O(n^2)` scans collapse into a single pass that uses the map as an oracle. From here you move into the paid track with **Sorting (Advanced)**, which trades hash-map lookups for divide-and-conquer to break the `O(n^2)` sorting barrier.

Not Started

0%

Algorithms
Hashing
Hash Map / Dictionary
Searching
Patterns
Problem Solving
Beginner
Free

Linked List Algorithms

Intermediate

55 min

2 prereqs

Reversing a singly linked list is a four-line iteration with three pointers (`prev`, `curr`, `next`), and yet roughly a third of candidates implement it incorrectly under interview pressure. The reason is that linked-list problems give you no random access: every operation has to be expressed as careful, ordered pointer rewrites, and one missed assignment loses the rest of the list forever. **Linked List Algorithms** is the lesson where pointer manipulation becomes a reliable skill. You will reverse a list iteratively and recursively, then extend the technique to reverse in groups of `k`. You will use Floyd's fast and slow pointers to detect cycles, find the cycle start, locate the middle element, and check whether a list is a palindrome. You will merge two sorted lists, then merge `k` sorted lists with a min-heap. The lesson also covers removing the nth node from the end, finding the intersection of two lists, deep-copying a list with random pointers, and the dummy-node trick that eliminates head-edge cases entirely. In **Linked Lists (Singly)**, you saw how nodes and `next` pointers form a list and why insertion at a known position is `O(1)`. **Two Pointers (Intro)** introduced fast and slow indices on arrays; this lesson reuses the same idea on pointer-linked nodes. Next, **Tree Algorithms** generalizes pointer-and-recursion thinking to branching structures.

Not Started

0%

Algorithms
Singly Linked List
Fast/Slow Pointers
Two Pointers
Cycle Detection
Patterns
Intermediate
Premium

Pattern Matching Algorithms

Advanced

55 min

1 prereq

Boyer-Moore is the algorithm `grep` actually uses, and it has a counterintuitive property: longer patterns make it _faster_, not slower, because the bad-character rule lets it skip whole chunks of the text without inspecting them. The best case is `O(n / m)`, sublinear in the text length. The same insight (start from the right, jump aggressively on mismatch) defines a different family of pattern-matching algorithms from the linear-scan family of KMP and Z. **Pattern Matching Algorithms** rounds out the string-search toolkit. You will implement Boyer-Moore with both the bad-character rule and the good-suffix rule, build a deterministic finite automaton (DFA) from a pattern and use the resulting state-transition table for `O(n)` matching after `O(m * |alphabet|)` preprocessing, and extend pattern search into two dimensions row by row. The lesson closes with a head-to-head comparison of every string-matching algorithm you have seen so far (KMP, Z, Rabin-Karp, Manacher, Aho-Corasick, Boyer-Moore, DFA), so you can pick the right tool for any matching task: long patterns, multi-pattern, streaming, or 2D. In **String Algorithms**, you mastered the failure-function family of linear-time matchers. This lesson adds the right-to-left family and the automaton-construction family. From here, **Advanced Greedy & Data Structures** turns to monotonic stacks.

Not Started

0%

Algorithms
Strings
String Matching
Patterns
Advanced
Premium
Comparison
Deep Dive

Prefix Sum & Difference Array

Free
Beginner

45 min

2 prereqs

Imagine an array of a million numbers and a thousand questions of the form "what is the sum of elements between index `l` and `r`?". The naive answer loops through each query, doing roughly a billion additions in total. Prefix sums turn the same workload into a million additions plus a thousand subtractions, with answers in constant time per query. **Prefix Sum & Difference Array** covers the technique in three layers. You will build 1D prefix sums where `prefix[i] = prefix[i-1] + arr[i]` and answer any range sum in `O(1)`. You will then learn the inverse, the difference array, which turns repeated `O(n)` range updates into `O(1)` updates that you reconstruct in a single final pass. The lesson finishes with 2D prefix sums and the inclusion-exclusion trick for answering submatrix sum queries, plus quick variants like prefix XOR and prefix product. In **Arrays & Strings**, you saw why arrays support `O(1)` random access; that property is exactly what makes prefix lookup possible. **Iteration Patterns on Arrays/Strings** trained you to think in terms of single passes, and the prefix sum is the first pattern where one preprocessing pass replaces an entire family of later loops. From here you will move into **Sorting (Elementary)**, where rearranging the array unlocks an entirely different class of techniques.

Not Started

0%

Algorithms
Prefix Sum
Difference Array
Range Queries
Arrays
Beginner
Free
Patterns

Two Pointers (Intro)

Free
Beginner

55 min

1 prereq

Given a sorted array and a target sum, the brute-force "check every pair" approach is `O(n^2)`. With two indices walking inward from opposite ends, the same problem drops to `O(n)`: if the current pair sums too low, move the left pointer right; if it sums too high, move the right pointer left. **Two Pointers (Intro)** turns that insight into a reusable pattern with two main shapes. The opposite-direction variant has pointers converge from both ends and powers problems like pair sum, palindrome check, reverse in place, and container with most water. The same-direction (fast and slow) variant has both pointers walk forward at different speeds and powers in-place filtering problems like remove duplicates from a sorted array, move zeros to the end, and the linked-list cycle detection you will revisit later. In **Arrays & Strings**, you learned how a single index walks across an array. This lesson coordinates two indices in a way that exploits sorted order or a structural invariant to skip work an inner loop would otherwise repeat. Next, **Sliding Window (Intro)** generalizes the same-direction pointer pair into an expanding and shrinking range that solves contiguous-subarray problems.

Not Started

0%

Algorithms
Two Pointers
Arrays
Fast/Slow Pointers
Patterns
Time Complexity
Beginner
Free

Community

10 items
Article

The Builder Pattern: When the Constructor Isn't Enough

The Builder pattern earns its keep when constructors blow up to ten parameters or when an object's invariants depend on a multi-step assembly. The shape, the cases that justify it, and the imitations that don't.

design-patterns
patterns
oop
constructors
encapsulation

866

6

4.4 (10)

May 3, 2026

by @weireeves

Article

Functional Core, Imperative Shell, Explained

The architecture pattern that gives you most of functional programming's testability without a rewrite. The two-layer rule, where each layer's responsibilities sit, and the failure modes of mixing them.

functional-programming
design-patterns
patterns
pure-functions
clean-code

376

9

4.2 (15)

Apr 30, 2026

by @gracebanda

Article

Composition Over Inheritance, with Real Examples

The slogan everyone repeats and almost no one operationalizes. What composition actually looks like at the field level, where inheritance is still right, and the refactor when you've gone too deep.

composition
inheritance
design-patterns
oop
patterns

203

1

4.1 (10)

Apr 8, 2026

by @liamreed

Article

The Strategy Pattern: The Cleanest Way to Kill an if-else Chain

Strategy is taught as an OO pattern, but in practice it is just a function with a name. How to recognize the if-else chains that genuinely deserve the refactor and the ones that don't.

strategy-pattern
design-patterns
oop
patterns
clean-code

592

9

4.3 (12)

Mar 4, 2026

by @marcusreddy

Article

Building Smarter Code: Singleton & Factory Method

Singleton is the pattern most teams over-apply, and Factory Method is the one most teams reach for too late. Where each pays off, where each rots, and the rules I follow.

singleton
factory-pattern
design-patterns
oop
patterns

769

5

4.2 (13)

Mar 1, 2026

by @aishataylor

Article

The Observer Pattern and Why React Rediscovered It

Observer is the pattern most engineers think they know, until they look at React's render loop, signals, or RxJS and realize each one is a different observer dialect. The shape, the variants, and the gotchas.

observer-pattern
design-patterns
event-driven
react
patterns

235

6

4.3 (14)

Feb 25, 2026

by @hannahdelgado

Article

The Decorator Pattern vs Language Decorators

The GoF Decorator pattern and Python's @decorator syntax share a name and almost nothing else. What each one really does, where they overlap, and the wrap order that catches everyone.

decorator-pattern
py-decorators
ts-decorators
design-patterns
patterns

662

7

4.2 (13)

Feb 23, 2026

by @kiranpatel

Article

Pure Functions, Immutability, and the Trade-offs

Pure functions and immutability are not free. The honest accounting of the wins (testability, reasoning, parallelism) and the costs (allocation, ergonomics, language fit), and where the line falls in real code.

pure-functions
immutability
functional-programming
design-patterns
patterns

595

2

4.2 (15)

Jan 31, 2026

by @imanichen

Article

Adapter and Facade: The Two Patterns I Actually Use

Two structural patterns that survive every codebase: Adapter (when you cannot change the other side) and Facade (when you cannot change yours). The shape of each, and the small tells that say which one fits.

design-patterns
patterns
oop
abstraction
encapsulation

1k

27

4.3 (12)

Dec 15, 2025

by @sanjayward

Article

Dependency Injection Without a Framework

DI is a pattern, not a framework. The plain-language version (pass things in instead of newing them inside) covers ninety percent of cases. The trade-off versus DI containers, and where each one breaks down.

design-patterns
patterns
oop
abstraction
testing

490

5

4.3 (14)

Dec 4, 2025

by @ramijohansson