HomeProblemsCheatsheetsConceptsDebuggingResume

Problems & Solutions

Click a solution to see an animated visualization, complexity, and explanation.

Minimum Window Substring (Characters)

Given a string and a set of required characters (including duplicates), find the smallest substring that contains all required characters. If no such substring exists, return an empty string.

Brute-force sliding windowSingle-pass sliding window

Component Tree Search

Given a nested component tree structure, return all components whose type matches a target value. The traversal must preserve top-to-bottom, left-to-right order.

Flatten with reduce + spreadFlatten with accumulator, then filterSingle-pass collector

Deduplicate While Preserving Order

Given a list of items with IDs, remove duplicates by ID while preserving the order of first occurrence.

Map by ID (first wins)

Dependency Resolution (Topological Sort)

Given a list of modules and dependency pairs where one module depends on another, return an order of modules that satisfies all dependencies. If a cycle exists, return an empty list.

Kahn's algorithm (BFS + indegree)

Event Rate Limiting (Rolling Window)

Given a time-ordered list of events, enforce a per-event-type rate limit such that no more than a fixed number of events occur within a rolling time window. Events exceeding the limit are dropped while preserving order.

Per-type queue + sliding window

Reverse Integer

Given a 32-bit signed integer, reverse its digits. Return 0 if the reversed value would overflow the 32-bit signed integer range. Preserve the sign of the input.

Digit extraction with place valuesPop digit (mod 10) with overflow check

Squares of a Sorted Array

Given an integer array sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. Use O(n) time and O(n) space (excluding output).

Two pointers (fill from end)

Binary Search (Sorted Array)

Given a sorted array of integers and a target value, return the index of the target if it exists, otherwise return -1. Use binary search: repeatedly compare the middle element to the target and narrow the search range.

Binary search (iterative)