Preploop

Practice Hub

Data Structures & Algorithms

Build muscle memory for common coding patterns. Rehearse sliding windows, two pointers, tree traversals, and sorting algorithms step-by-step with interactive trace arrays.

42 CODING PATTERNS LIVE
Practice Lab · Arrays & Strings

Two Pointers

Two indices scanning toward each other or at different speeds

  • O(n) Complexity
  • Space: O(1)
Practice Lab · Arrays & Strings

Sliding Window

Maintain a window of elements — expand right, shrink left

  • O(n) Complexity
  • Space: O(1)
Practice Lab · Arrays & Strings

Prefix Sum

Pre-compute cumulative sums for O(1) range queries

  • O(n) build, O(1) query Complexity
  • Space: O(N)
Practice Lab · Arrays & Strings

Kadane's Algorithm

Maximum subarray sum — keep running total or restart

  • O(n) Complexity
  • Space: O(1)
Practice Lab · Arrays & Strings

Cyclic Sort

Place each number at its correct index in O(n)

  • O(n) Complexity
  • Space: O(1)
Practice Lab · Arrays & Strings

Boyer-Moore Voting

Cancel opposing votes — the majority survives

  • O(n) Complexity
  • Space: O(1)
Practice Lab · Arrays & Strings

Dutch National Flag

Three-way partition with low / mid / high pointers

  • O(n) Complexity
  • Space: O(1)
Practice Lab · Search Algorithms

Binary Search

Halve the search space every step — O(log n) on sorted data

  • O(log n) Complexity
  • Space: O(1)
Practice Lab · Search Algorithms

Binary Search on Answer

Binary search over the answer space, not the array

  • O(n log(max-min)) Complexity
  • Space: O(1)
Practice Lab · stack

Monotonic Stack

Stack that stays sorted — find next greater/smaller in O(n)

  • O(n) Complexity
  • Space: O(N)
Practice Lab · stack

Monotonic Queue

Deque that keeps window max/min reachable in O(1)

  • O(n) Complexity
  • Space: O(K)
Practice Lab · stack

Balanced Parentheses

Use a stack to match opening and closing brackets

  • O(n) Complexity
  • Space: O(N)
Practice Lab · Linked Lists

Fast & Slow Pointers

Floyd's cycle detection — slow moves 1 step, fast moves 2

  • O(n) Complexity
  • Space: O(1)
Practice Lab · Linked Lists

LinkedList Reversal

In-place reversal with three pointers: prev / curr / next

  • O(n) Complexity
  • Space: O(1)
Practice Lab · Linked Lists

K-way Merge

Min-heap tracks the front of K sorted lists

  • O(n log k) Complexity
  • Space: O(K)
Practice Lab · Trees & Graphs

BFS Level Order

Queue processes the tree level by level

  • O(n) Complexity
  • Space: O(W)
Practice Lab · Trees & Graphs

DFS Traversal

Recurse into children — pre / in / post order

  • O(n) Complexity
  • Space: O(H)
Practice Lab · Trees & Graphs

Tree DP

Compute each subtree's answer bottom-up

  • O(n) Complexity
  • Space: O(H)
Practice Lab · Trees & Graphs

Lowest Common Ancestor

Deepest node that is an ancestor of both targets

  • O(n) Complexity
  • Space: O(H)
Practice Lab · Trees & Graphs

Trie (Prefix Tree)

Tree of characters for fast prefix lookups

  • O(L) per op Complexity
  • Space: O(N·L)
Practice Lab · graphs

BFS/DFS Islands

Flood-fill connected components in a grid

  • O(rows·cols) Complexity
  • Space: O(ROWS·COLS)
Practice Lab · graphs

Topological Sort

Order a DAG so every edge points forward

  • O(V+E) Complexity
  • Space: O(V+E)
Practice Lab · graphs

Union-Find (DSU)

Track connected components with path compression

  • O(α(n)) per op Complexity
  • Space: O(N)
Practice Lab · graphs

Dijkstra's Shortest Path

Greedy shortest paths with a min-heap

  • O(E log V) Complexity
  • Space: O(V)
Practice Lab · graphs

Bellman-Ford

Relax all edges V-1 times — handles negative weights

  • O(V·E) Complexity
  • Space: O(V)
Practice Lab · graphs

Multi-source BFS

Start BFS from all sources at once

  • O(rows·cols) Complexity
  • Space: O(ROWS·COLS)
Practice Lab · dp

1D DP (Fibonacci)

Current state depends on the last 1–2 states

  • O(n) Complexity
  • Space: O(1)
Practice Lab · dp

0/1 Knapsack

Include or exclude each item once

  • O(n·W) Complexity
  • Space: O(W)
Practice Lab · dp

Unbounded Knapsack

Each item can be picked unlimited times

  • O(n·W) Complexity
  • Space: O(W)
Practice Lab · dp

Longest Common Subsequence

2D table — characters match or skip one

  • O(m·n) Complexity
  • Space: O(M·N)
Practice Lab · dp

Longest Increasing Subsequence

Patience sorting — binary search the tails

  • O(n log n) Complexity
  • Space: O(N)
Practice Lab · dp

Matrix / Grid DP

Fill a grid from top-left to bottom-right

  • O(m·n) Complexity
  • Space: O(N)
Practice Lab · dp

Interval DP

Solve ranges by trying every split point

  • O(n³) Complexity
  • Space: O(N²)
Practice Lab · dp

State Machine DP

Track distinct states that transition on decisions

  • O(n·k) Complexity
  • Space: O(K)
Practice Lab · heap

Top K Elements

A size-K heap keeps the best K seen so far

  • O(n log k) Complexity
  • Space: O(K)
Practice Lab · heap

Two Heaps (Median)

Max-heap (low half) + min-heap (high half)

  • O(log n) add Complexity
  • Space: O(N)
Practice Lab · heap

K-way Merge (Heap)

Heap of K list-fronts merges sorted sources

  • O(n log k) Complexity
  • Space: O(K)
Practice Lab · backtracking

Subsets / Combinations

At each index: choose it or skip it

  • O(2ⁿ) Complexity
  • Space: O(N)
Practice Lab · backtracking

Permutations

Swap, recurse, swap back

  • O(n!) Complexity
  • Space: O(N)
Practice Lab · backtracking

Constraint Satisfaction

Place, validate, prune invalid branches

  • O(exp) Complexity
  • Space: O(N)
Practice Lab · greedy

Interval Scheduling

Sort by end time, greedily take the earliest finish

  • O(n log n) Complexity
  • Space: O(1)
Practice Lab · greedy

Jump Game

Track the farthest index reachable so far

  • O(n) Complexity
  • Space: O(1)

One rehearsal platform

Certification mocks, daily lessons, project labs, and in-browser drills

Structured for exam day and portfolio proof — timed tests, guided builds, and quick reps on one platform.