See the pattern behind the problem.
Learn the signals that turn an unfamiliar question into a familiar approach.
Can you spot the right approach?
Short questions. Useful explanations. Sharper intuition.
Arrays
A sequence gives every value an index. First decide what information a single pass can maintain.
Learn the signalsStrings
Treat text as a sequence, but define what counts as a character before choosing indices.
Learn the signalsHashMap
Trade a little memory for fast answers to: have I seen the value I need?
Learn the signalsHashSet
Remember membership without storing a separate associated value.
Learn the signalsTwo Pointers
Maintain two positions whose movement preserves a useful relationship: mirrored characters, a compacted prefix, or a sorted pair sum.
Learn the signalsSliding Window
Maintain a contiguous range, reusing information as its boundaries move.
Learn the signalsPrefix Sum
Store the sum of each prefix so an inclusive range can be expressed as the difference of two prefixes.
Learn the signalsSorting
Reorder values by a chosen key so local comparisons reveal global structure, such as neighboring overlapping ranges.
Learn the signalsBinary Search
A comparison proves that one half of the remaining candidates cannot contain the answer.
Learn the signalsLinked List
Follow identity-based links between nodes; position is reached by traversal rather than indexing.
Learn the signalsStack
The most recent unfinished task must be resolved first.
Learn the signalsQueue
Process items in the order they were discovered. The oldest unfinished item leaves first.
Learn the signalsDeque
Remove or add candidates at either end to maintain a useful frontier, such as decreasing values for window maxima.
Learn the signalsRecursion
Solve a smaller instance and keep unfinished work in a call frame.
Learn the signalsBacktracking
Explore a decision tree by choosing an option, solving the smaller remaining task, and undoing the choice before trying another option.
Learn the signalsFast & Slow Pointers
Follow a deterministic sequence at two speeds to detect a cycle without storing every visited state.
Learn the signalsTrees
A node owns smaller subtrees. Many global answers can be assembled from child answers.
Learn the signalsBinary Search Tree
Ordering applies to whole subtrees: every left descendant is smaller and every right descendant is greater under a strict-key policy.
Learn the signalsHeap / Priority Queue
Keep the best-priority item at the root while maintaining only parent–child order, rather than sorting every element.
Learn the signalsTrie
Share character-by-character paths so every node represents a prefix and can retain information about words with that prefix.
Learn the signalsGraphs
Model entities as vertices and relationships as edges, including implicit edges in a grid.
Learn the signalsDFS
Explore one branch as far as possible before returning to other frontier entries.
Learn the signalsBFS
Explore vertices in increasing number of edges from the start, using a queue to finish one distance layer before the next.
Learn the signalsTopological Sort
Resolve a directed dependency graph by repeatedly removing vertices with no remaining incoming edges.
Learn the signalsUnion Find
Represent disjoint components by rooted parent forests and merge components by linking their roots.
Learn the signalsDijkstra
Finalize the nearest unfinished vertex, then relax outgoing edges to improve tentative distances to other vertices.
Learn the signalsShortest Path
Associate each vertex with the least cost of reaching it under the problem's allowed moves.
Learn the signalsDynamic Programming
Define a reusable answer for each state, then compute states from already solved smaller ones.
Learn the signalsGreedy
Keep the strongest reachable state when a local choice can be proven to preserve every future possibility.
Learn the signalsIntervals
Represent each range by its endpoints and sort by start so overlapping groups can be processed in one sweep.
Learn the signalsBit Manipulation
Use bitwise identities to combine integer state. XOR has identity zero and cancels equal pairs.
Learn the signals