Practice Discrete Math

Algorithmic Thinking and Complexity

Big-O, loop analysis, graph algorithms, invariants, and developer-focused discrete math.

82 lessons · 410 questions

Algorithmic Thinking and Complexity

Big-O, loop analysis, graph algorithms, invariants, and developer-focused discrete math.

82 lessons · 410 questions

Answer Space Binary Search

1 lessons · 5 questions

Least You Need to Know: Binary Search on Answers and Monotone Predicates

Sometimes you do not binary-search an array index at all. Instead you binary-search an **answer space** such as a capacity, time limit, or threshold, using a feasibility check that flips from false to true exactly once.

Open lesson

Asymptotic Analysis

1 lessons · 5 questions

Least You Need to Know: Big-O, Theta, and Omega

Asymptotic notation compares growth rates. **Big-O** gives an eventual upper bound, **Omega** gives a lower bound, and **Theta** means the growth is tightly sandwiched between both.

Open lesson

Asymptotic Scenarios

1 lessons · 5 questions

Least You Need to Know: Mixed Big-O Scenarios

Mixed runtime questions combine scans, sorts, hash-table operations, and nested loops. Write each phase separately, then simplify to the dominant term.

Open lesson

Backtracking State Space

1 lessons · 5 questions

Least You Need to Know: Backtracking as Search Over Partial Choices

Backtracking explores a **state space of partial decisions**. The key idea is to build a candidate step by step, detect impossible or completed states early, and undo choices cleanly when a branch cannot lead to a valid answer.

Open lesson

Bfs Shortest Path

1 lessons · 5 questions

Least You Need to Know: BFS Layers, Unweighted Shortest Paths, and Multi-Source Search

Breadth-first search works on **unweighted** graphs because it explores states in layers of equal edge distance. That layer structure is the interview reason BFS gives shortest-path lengths when every move costs the same.

Open lesson

Binary Lifting

1 lessons · 5 questions

Least You Need to Know: Binary Lifting, Power-of-Two Jumps, and Ancestor Queries

Binary lifting preprocesses jump pointers so ancestor movement can be decomposed into **powers of two**. The main trick is the same as binary representation: any jump length can be written as a sum of power-of-two jumps.

Open lesson

Binary Search Invariants

1 lessons · 5 questions

Least You Need to Know: Binary Search Invariants and Boundary Updates

Binary search works because the search interval maintains an **invariant**: the desired answer is still inside the remaining range. Each comparison must eliminate only the half that is provably impossible, and the boundary update must match the exact question being asked.

Open lesson

Bipartite Matching Depth

1 lessons · 5 questions

Least You Need to Know: Bipartite Matching, Augmenting Paths, and Assignment Structure

Bipartite matching pairs vertices from two sides without reuse. The central progress idea is an **augmenting path**: alternating matched and unmatched edges that increases the matching size by one.

Open lesson

Bit Count Power

1 lessons · 5 questions

Least You Need to Know: Set Bits, Powers of Two, and Lowest-Bit Tricks

Many classic bit problems rely on what happens to the **lowest set bit**. That viewpoint explains power-of-two checks, efficient bit counting, and several constant-time transformations that show up repeatedly in interviews.

Open lesson

Bit Mixed Interview

1 lessons · 5 questions

Least You Need to Know: Bit Reasoning Depth and Mixed Interview Drills

This tranche pushes bit reasoning one step further, then mixes it with asymptotics, graphs, and invariants the way interview questions often do.

Open lesson

Bitmask Set

1 lessons · 5 questions

Least You Need to Know: Bitmasks as Sets, Flags, and Small-State Compression

A bitmask can represent membership in a small universe using one integer. This lets interviews compress sets, feature flags, visited states, and eligibility rules into fast bitwise operations.

Open lesson

Bitwise Logic

1 lessons · 5 questions

Least You Need to Know: AND, OR, XOR, and Single-Bit Updates

Bitwise operators treat integers as compact boolean vectors. Interview problems use this to test parity, flip flags, cancel duplicates with XOR, and update one bit at a time in constant space.

Open lesson

Boolean And Bits

1 lessons · 5 questions

Least You Need to Know: Boolean Algebra and Bit Reasoning

Developers constantly reason about boolean conditions, feature flags, masks, and low-level binary properties. Discrete math logic becomes practical when you simplify conditions and interpret bitwise operations correctly.

Open lesson

Bridges Articulation

1 lessons · 5 questions

Least You Need to Know: Bridges, Articulation Points, and Fragile Connectivity

Bridges and articulation points identify where an undirected graph is **fragile**. A bridge is an edge whose removal disconnects the graph; an articulation point is a vertex whose removal does the same.

Open lesson

Bst Invariants

1 lessons · 5 questions

Least You Need to Know: BST Invariants, Search Ranges, and Inorder Structure

Binary-search-tree reasoning is about **global range constraints**, not just comparing a node to its direct children. Inorder traversal is sorted precisely because every left subtree stays below the node and every right subtree stays above it.

Open lesson

Condensation Dag

1 lessons · 5 questions

Least You Need to Know: Condensation DAGs and Component-Level Ordering

If each SCC is contracted to one node, the resulting graph is a **DAG**. This condensation DAG captures the one-way flow between strongly connected regions and is often the right object for topological reasoning after SCC decomposition.

Open lesson

Coordinate Compression

1 lessons · 5 questions

Least You Need to Know: Coordinate Compression, Order Preservation, and Dense Indexing

Coordinate compression replaces sparse or huge values with a dense rank order while preserving **relative order comparisons**. It is a preprocessing bridge between messy input values and array-based data structures.

Open lesson

Dags And Paths

1 lessons · 5 questions

Least You Need to Know: Topological Order, DAGs, and Path Intuition

A **topological order** lists the vertices of a directed acyclic graph so every edge points forward in the list. DAG thinking shows up in build systems, prerequisite planning, dependency graphs, and many workflow pipelines.

Open lesson

Deque Design Tradeoffs

1 lessons · 5 questions

Least You Need to Know: Deques, Front/Back Operations, and Design Tradeoffs

A deque supports insertion and removal at both ends, so it can imitate either a stack or a queue and can also handle patterns that need both. Interview questions use deques when a single-end structure would be too restrictive.

Open lesson

Difference Arrays

1 lessons · 5 questions

Least You Need to Know: Difference Arrays, Boundary Marking, and Range Updates

Difference arrays invert the prefix-sum idea: instead of storing cumulative totals directly, they store **where changes begin and end**. After marking update boundaries, one prefix sweep reconstructs the final values.

Open lesson

Dp Memo Vs Tabulation

1 lessons · 5 questions

Least You Need to Know: Memoization vs Tabulation

Memoization and tabulation solve the same recurrence in different directions. Interview questions often ask when one is simpler, when one avoids wasted work, and how iteration order reflects dependencies.

Open lesson

Dp Mixed Interview

1 lessons · 5 questions

Least You Need to Know: Dynamic Programming Mixed Interview Drills

Interview DP questions rarely ask only for a recurrence. They mix state design, dependency order, asymptotics, and correctness traps like double counting or forgetting part of the state.

Open lesson

Dp State Design

1 lessons · 5 questions

Least You Need to Know: Dynamic Programming State Design

Dynamic programming starts by choosing a state that remembers exactly the information a smaller subproblem needs. Good state design is usually the difference between a clean recurrence and a confused one.

Open lesson

Dp Subproblem Graph

1 lessons · 5 questions

Least You Need to Know: DP as a Subproblem Graph

A recurrence defines a directed graph of dependencies between states. Thinking of DP as a DAG clarifies overlapping subproblems, iteration order, and why cycles are a warning sign.

Open lesson

Euler Tour Subtree Ranges

1 lessons · 5 questions

Least You Need to Know: Euler Tours, Subtree Intervals, and Flattened Trees

An Euler-tour-style entry order can flatten a rooted tree so each subtree becomes a **contiguous interval** in an array. That converts many subtree problems into familiar range-query problems.

Open lesson

Fast Slow Pointers

1 lessons · 5 questions

Least You Need to Know: Fast/Slow Pointers, Middle Nodes, and Cycle Entry

Fast and slow pointers turn repeated traversal into relative-motion reasoning. The same idea explains finding middle nodes, detecting linked-list cycles, and locating the entry point after a cycle is found.

Open lesson

Fenwick Tree Point Update

1 lessons · 5 questions

Least You Need to Know: Fenwick Point Updates, Frequencies, and Order Statistics

Point updates in a Fenwick tree climb upward through the indices whose stored partial sums include the changed position. This makes the structure especially useful for dynamic frequency tables and coordinate-compressed counting problems.

Open lesson

Fenwick Tree Prefix Sum

1 lessons · 5 questions

Least You Need to Know: Fenwick Trees, Prefix Sums, and Low-Bit Jumps

Fenwick trees support prefix-sum queries and point updates in `O(log n)` by storing carefully chosen partial sums. The key bit trick is the low bit, which tells how large a range each index is responsible for.

Open lesson

Graph Cycle Detection

1 lessons · 5 questions

Least You Need to Know: Cycle Detection in Directed and Undirected Graphs

Cycle detection depends on graph type. In undirected graphs, you must ignore the edge back to the parent. In directed graphs, the key signal is whether DFS re-enters a node that is still on the current recursion path.

Open lesson

Graph Modeling State Space

1 lessons · 5 questions

Least You Need to Know: Modeling Interview Problems as Graph Search

Many interview problems become easier once you name the **state** and the **moves**. When states become vertices and legal moves become edges, familiar tools like BFS and DFS suddenly apply.

Open lesson

Graph Traversal

1 lessons · 5 questions

Least You Need to Know: BFS, DFS, and Connected Components

**Breadth-first search** explores layer by layer, while **depth-first search** follows one path deeply before backtracking. Both are core graph tools, and both can be used to discover reachability and connected components.

Open lesson

Greedy Exchange Arguments

1 lessons · 5 questions

Least You Need to Know: Greedy Choice, Exchange Arguments, and Local Decisions

Greedy algorithms succeed when a **locally optimal step** can be justified as part of some globally optimal solution. Exchange arguments and staying-ahead arguments explain why taking a certain next move never makes the final answer worse.

Open lesson

Grid Graph Traversal

1 lessons · 5 questions

Least You Need to Know: Grid Traversal, Flood Fill, and Boundary Checks

Many interview grid problems are just implicit graph traversal: each cell is a node, legal moves define edges, and BFS or DFS visits connected components or shortest paths. The main implementation risk is careful neighbor and boundary handling.

Open lesson

Heap Frontier Top K

1 lessons · 5 questions

Least You Need to Know: K-Way Merge, Top-K, and Heap Frontier Ideas

Heaps are useful when many sorted or partially ordered sources expose only a few promising next candidates. The heap stores the current **frontier** so you can pop the next best item without materializing every unseen option.

Open lesson

Heap Invariants

1 lessons · 5 questions

Least You Need to Know: Heaps, Heap Invariants, and Fast Extremes

A heap stores items so the **root is always the minimum or maximum** according to a priority rule. It does not fully sort everything, but it lets you update the frontier quickly when you repeatedly need the next best element.

Open lesson

Interval Overlap Meeting Rooms

1 lessons · 5 questions

Least You Need to Know: Interval Overlap, Meeting Rooms, and End-Time Heaps

Some interval problems are not about choosing one compatible subset. Instead they ask for the **maximum number of overlapping intervals** at any moment, or equivalently the minimum number of rooms needed to host them all. A min-heap of end times tracks how many intervals are active right now.

Open lesson

Interval Scheduling Greedy

1 lessons · 5 questions

Least You Need to Know: Interval Scheduling and Earliest-Finish Greedy

For maximizing how many non-overlapping intervals you can keep, the standard greedy rule is to sort by **earliest finishing time** and repeatedly accept the next compatible interval. The reason is that earlier finishes preserve more room for future choices.

Open lesson

Invariants And Structures

1 lessons · 5 questions

Least You Need to Know: Invariants and Structural Induction

Loop invariants explain why iterative algorithms stay correct after every update. Structural induction is the matching proof idea for recursive data structures such as lists and trees.

Open lesson

Lca

1 lessons · 5 questions

Least You Need to Know: Lowest Common Ancestors and Path Intersections

The lowest common ancestor of two nodes is the **deepest node lying on both root-to-node paths**. LCA problems become easy once you think in terms of path overlap rather than arbitrary tree geometry.

Open lesson

Linked List Dummy Nodes

1 lessons · 5 questions

Least You Need to Know: Dummy Nodes, Head Cases, and Stable Stitching

A dummy node is a fake node placed before the real head so that insertion and deletion at the front look like ordinary middle-of-list operations. Interviews love dummy nodes because they remove special-case branching and make stitched-together outputs easier to reason about.

Open lesson

Linked List Pointer Updates

1 lessons · 5 questions

Least You Need to Know: Linked-List Pointer Updates and Local Rewiring

Linked-list problems are about **preserving access while changing arrows**. Because each node only knows its next pointer, interviews reward students who save the next node before rewiring and who reason locally about what each pointer update does to the rest of the list.

Open lesson

Linked List Reversal

1 lessons · 5 questions

Least You Need to Know: Reversing a Linked List with Prev, Current, and Next

Linked-list reversal is the interview archetype for pointer discipline: keep track of what was before, what you are on, and what comes next. The core invariant is that one prefix has already been reversed while the remaining suffix is still untouched.

Open lesson

Linked List Sorted Merge

1 lessons · 5 questions

Least You Need to Know: Merging Sorted Lists and Splicing Runs

Sorted linked-list merge is a classic interview pattern because the lists are already ordered, so you can advance exactly one front pointer at a time. The algorithm is linear in the total number of nodes and is often implemented cleanly with a dummy head.

Open lesson

Loop Analysis

1 lessons · 5 questions

Least You Need to Know: Analyzing Loops and Nested Loops

For loop analysis, count how many times the body executes and multiply by the work per execution. Nested loops often multiply counts, while doubling or halving patterns often lead to logarithms.

Open lesson

Modular Arithmetic

1 lessons · 5 questions

Least You Need to Know: Modular Arithmetic, Divisibility, and Hashing Intuition

Modular arithmetic tracks remainders. That matters in parity, clock arithmetic, hashing buckets, wrap-around indexing, and many programming tasks involving periodic behavior.

Open lesson

Modular Hashing Depth

1 lessons · 5 questions

Least You Need to Know: Modular Arithmetic and Hashing Depth

Deeper modular reasoning shows up when you compare residue classes, predict collisions, combine congruences, and reason about how bucket counts interact with patterned inputs.

Open lesson

Monotonic Deque Prefix Sum

1 lessons · 5 questions

Least You Need to Know: Monotonic Deques, Prefix Sums, and Shortest Valid Windows

Some subarray problems use prefix sums plus a monotonic deque over prefix indices. The deque keeps promising earlier prefixes in increasing order so the current prefix can quickly detect the shortest earlier start that already makes the sum large enough.

Open lesson

Monotonic Queue Sliding Window

1 lessons · 5 questions

Least You Need to Know: Monotonic Queues and Sliding-Window Extremes

A monotonic deque keeps the current window's best candidates in order, so the front always holds the maximum or minimum. It is the standard pattern for sliding-window extrema because it supports both expiration from the left and dominance cleanup from the right.

Open lesson

Monotonic Stack Boundaries

1 lessons · 5 questions

Least You Need to Know: Monotonic Stacks for Range Boundaries and Histogram Areas

Monotonic stacks do more than next-greater queries: they also expose the nearest smaller or larger boundary on each side. That boundary view powers classic problems like largest rectangle in a histogram and contribution counting.

Open lesson

Monotonic Stack Next Greater

1 lessons · 5 questions

Least You Need to Know: Monotonic Stacks and Next-Greater Patterns

A monotonic stack keeps elements in sorted stack order so that a new value can resolve many waiting positions at once. This turns repeated scanning into a single left-to-right pass for next-greater and waiting-time style problems.

Open lesson

Offline Sorting Sweep

1 lessons · 5 questions

Least You Need to Know: Offline Sorting, Event Sweeps, and Ordered Processing

Offline processing sorts updates, queries, or events by a key so work can be done in one monotone sweep. The key insight is to answer many questions by **maintaining a moving frontier** rather than restarting from scratch for each query.

Open lesson

Palindrome Manacher Lite

1 lessons · 5 questions

Least You Need to Know: Palindrome Centers, Symmetry, and Manacher-Lite Intuition

Palindrome reasoning starts from centers and symmetry. Manacher's algorithm pushes that idea further by reusing information from the current rightmost palindrome to compute all palindrome radii in linear time.

Open lesson

Partitioning Dutch Flag

1 lessons · 5 questions

Least You Need to Know: Partitioning Invariants and Dutch-Flag Regions

Partition algorithms maintain region invariants while scanning an unknown middle segment. This is the interview core behind quickselect-style partitioning, Dutch-flag sorting, and in-place grouping by a pivot or category.

Open lesson

Permutations Constraints Search

1 lessons · 5 questions

Least You Need to Know: Permutations, Used Sets, and Constraint Propagation

Permutation search cares about **order**, so each recursive level chooses the next position from items not yet used. Constraint checks can often be applied to the growing prefix to reject bad permutations early.

Open lesson

Prefix Function Kmp

1 lessons · 5 questions

Least You Need to Know: Prefix Function, Borders, and KMP Intuition

The **prefix function** tracks how much of a pattern already matches itself. That self-overlap information is what lets KMP avoid restarting from scratch after mismatches in pattern matching problems.

Open lesson

Prefix Sums

1 lessons · 5 questions

Least You Need to Know: Prefix Sums, Range Aggregates, and Subtracting History

Prefix sums precompute cumulative totals so a range sum becomes **one subtraction of two histories**. This is one of the highest-leverage preprocessing tricks in algorithmic problem solving.

Open lesson

Priority Queue Patterns

1 lessons · 5 questions

Least You Need to Know: Priority Queues, Scheduling, and Lazy Updates

A priority queue turns a heap into an algorithmic tool: keep many candidates, then repeatedly extract the **currently best** one. This pattern appears in scheduling, event simulation, shortest-path style relaxations, and systems that reinsert improved priorities over time.

Open lesson

Queue Fifo Bfs Simulation

1 lessons · 5 questions

Least You Need to Know: Queues, FIFO Order, and Level-by-Level Simulation

Queues model situations where the earliest discovered or earliest arrived item should be processed first. That makes queues the natural frontier structure for breadth-first search and many step-by-step simulations.

Open lesson

Recurrence Analysis

1 lessons · 5 questions

Least You Need to Know: Recursion Trees and Recurrence Intuition

Recurrences describe recursive runtime by combining the cost of smaller subproblems with the non-recursive work done at each step. Recursion trees help you see branching, depth, and total work level by level.

Open lesson

Recurrence Patterns

1 lessons · 5 questions

Least You Need to Know: Recurrence Patterns for Interviews

Interview-style recurrence questions usually reduce to a few recognizable patterns. Ask whether the size shrinks by division or subtraction, how many branches appear, and what each level costs.

Open lesson

Recursion Tree Pruning

1 lessons · 5 questions

Least You Need to Know: Recursion Trees, Feasibility Checks, and Pruning

A recursion tree shows the search branches a backtracking algorithm may explore. **Pruning** means cutting off branches as soon as a partial state can no longer lead to a valid or useful solution.

Open lesson

Rolling Hash Substrings

1 lessons · 5 questions

Least You Need to Know: Rolling Hashes and Substring Fingerprints

A **rolling hash** gives a compact fingerprint for a substring so adjacent windows can be compared or updated quickly. Interview prompts use it for repeated-substring checks, duplicate-window detection, and fast candidate comparison.

Open lesson

Scc

1 lessons · 5 questions

Least You Need to Know: Strongly Connected Components and Mutual Reachability

A strongly connected component in a directed graph is a maximal set of vertices that can all reach one another. SCCs reveal the graph's cyclic cores and compress repeated mutual-reachability structure into components.

Open lesson

Segment Tree Lazy Propagation

1 lessons · 5 questions

Least You Need to Know: Lazy Propagation for Range Updates and Range Queries

Lazy propagation lets a segment tree postpone pushing range updates into children until that detail is actually needed. The main idea is to keep a pending tag that says, in effect, 'this whole interval has already been updated even if the children are not individually refreshed yet.'

Open lesson

Segment Tree Range Query

1 lessons · 5 questions

Least You Need to Know: Segment Trees, Range Queries, and Overlap Cases

Segment trees recursively partition an array into intervals so that range aggregates can be answered in `O(log n)` by combining a small number of stored interval results. The key interview idea is to reason about **no overlap**, **partial overlap**, and **complete overlap**.

Open lesson

Sliding Window Strings

1 lessons · 5 questions

Least You Need to Know: Two Pointers, Sliding Windows, and String Scans

Many interview string problems are not about deep string theory. They are about keeping a **contiguous window** consistent while scanning left to right. The key question is what summary of the current window lets you expand, shrink, and answer the prompt in overall linear time.

Open lesson

Sparse Table Rmq

1 lessons · 5 questions

Least You Need to Know: Sparse Tables, RMQ, and Static Idempotent Queries

Sparse tables preprocess answers for intervals of length power of two. They shine on **static arrays** and especially on idempotent operations like minimum, where overlapping power-of-two blocks can answer a query in `O(1)`.

Open lesson

Stack Balanced Delimiters

1 lessons · 5 questions

Least You Need to Know: Stacks, Balanced Delimiters, and Most-Recent Openings

Balanced-parentheses problems are stack problems because each closing bracket must match the **most recent unmatched opening**. That last-opened, first-closed behavior is exactly LIFO order.

Open lesson

Stack Expression Evaluation

1 lessons · 5 questions

Least You Need to Know: Stacks, Postfix Evaluation, and Expression State

Stacks evaluate postfix expressions because operands arrive before the operator that combines them. When the operator appears, the most recent operands are popped, combined, and the result is pushed back for later use.

Open lesson

Subset Enumeration Bitmask

1 lessons · 5 questions

Least You Need to Know: Bitmask Subset Enumeration and Used-Set State

Enumerating masks from `0` to `2^n - 1` gives every subset of an `n`-element set. Interviews use this for subset generation, used-element state, and small-state dynamic programming where each bit records a chosen item.

Open lesson

Subsets Combinations Search

1 lessons · 5 questions

Least You Need to Know: Subsets, Combinations, and Choose/Skip Search

Subset and combination search usually depends on a **choose/skip** structure. The important distinction is that order does not matter, so the recursion should move forward through candidates instead of revisiting earlier positions.

Open lesson

Suffix Ordering

1 lessons · 5 questions

Least You Need to Know: Suffix Ordering, Lexicographic Structure, and LCP Intuition

Suffix-based reasoning sorts all suffixes of a string lexicographically. Even without implementing a full suffix array from scratch, it helps to know how lexicographic suffix order exposes repeated-substring structure and longest-common-prefix reasoning.

Open lesson

Topological Sort Dag

1 lessons · 5 questions

Least You Need to Know: Topological Sort, DAG Dependencies, and Prerequisite Order

Topological sorting gives an order that respects directed dependencies: every edge points from something that must come earlier to something that may come later. It only works when the graph is a **DAG**.

Open lesson

Tree Dp Rerooting

1 lessons · 5 questions

Least You Need to Know: Tree DP, Child-State Combination, and Rerooting Intuition

Tree dynamic programming works because each node can summarize its subtree from its children. Rerooting extends that idea by reusing previously computed information when the root perspective shifts from one node to another.

Open lesson

Tree Height Balance

1 lessons · 5 questions

Least You Need to Know: Tree Height, Balance, and Diameter Intuition

Bottom-up tree questions ask each subtree to return a small summary such as its height, whether it is balanced, or the best path seen so far. The key interview move is to decide what summary the parent needs from each child.

Open lesson

Tree Traversal Recursion

1 lessons · 5 questions

Least You Need to Know: Tree Traversals and Recursive Calls

Tree interview questions often hinge on **when** work happens relative to the recursive calls. Preorder acts before the children, inorder acts between them, and postorder acts after the children return.

Open lesson

Trie Hash Kmp Tradeoffs

1 lessons · 5 questions

Least You Need to Know: Trie vs Hash vs KMP Tradeoffs for String Tasks

String problems often hinge on the right representation. Tries help with many shared prefixes, hashing helps with fast average-case lookup or substring fingerprints, and KMP helps with exact pattern matching without backtracking in the text.

Open lesson

Tries Prefix Search

1 lessons · 5 questions

Least You Need to Know: Tries, Prefix Search, and Shared Prefix Structure

A **trie** stores strings by characters along root-to-node paths. It is useful when many words share prefixes and the interview task asks about prefix lookup, autocomplete, or word-search branching.

Open lesson

Two Pointers Compaction

1 lessons · 5 questions

Least You Need to Know: Read/Write Pointers, Compaction, and Deduping

A read pointer examines every element while a write pointer marks where the next kept element belongs. This is the core interview pattern for in-place filtering, removing duplicates, and compacting arrays without extra output storage.

Open lesson

Two Pointers Sorted Pairs

1 lessons · 5 questions

Least You Need to Know: Opposite-End Two Pointers and Sorted Pair Search

When data order lets you predict how a sum or comparison changes, **two pointers** can eliminate large parts of the search space without backtracking. This is the interview reason sorted-pair, palindrome, and container-style problems collapse from quadratic scanning to linear passes.

Open lesson

Union Find Connectivity

1 lessons · 5 questions

Least You Need to Know: Union-Find for Connectivity and Cycles

Union-find, also called **disjoint set union (DSU)**, tracks which items currently belong to the same connected component. It is especially useful when edges are added over time and you need fast connectivity or redundant-edge reasoning.

Open lesson

Z Function

1 lessons · 5 questions

Least You Need to Know: Z-Function, Prefix Matches, and Pattern Search by Concatenation

The Z-function at position `i` stores the length of the longest substring starting at `i` that matches the whole string prefix. This lets you reason about repeated prefix structure and perform pattern search via concatenation.

Open lesson