Skip to contentKEEP THE CRAFTTHE SANCTUARY

The Skills

93 reviewed skills: the patterns, data structures and algorithms that carry interview problems. Each opens in the reading room with how to recognise it, the invariant to say aloud and the problems where it matters.

The skills shelf

93 skills

Family
  1. 2D Prefix SumPatternUse cumulative matrix regions and inclusion-exclusion to answer rectangular range queries.
  2. Binary Search on AnswerPatternBinary-search a monotone feasibility predicate when the answer lies in an ordered numeric space.
  3. Choose / Explore / UnchoosePatternBuild candidates recursively, prune invalid states, and undo each choice during backtracking.
  4. Constraint SatisfactionPatternSearch assignments incrementally while pruning partial states that violate constraints.
  5. Cyclic SortPatternPlace values into index-derived positions to find missing, duplicate, or misplaced elements in place.
  6. Difference ArrayPatternEncode range updates at boundaries and reconstruct final values with a prefix accumulation.
  7. Fast and Slow PointersPatternAdvance pointers at different speeds to detect cycles, middles, or repeated state.
  8. Fixed-size WindowPatternSlide a window of constant length while adding the entering value and removing the leaving value.
  9. In-place Index MappingPatternReuse array positions as state when values have a bounded relationship to valid indices.
  10. Interval DPPatternSolve progressively larger contiguous intervals by combining solutions around split points.
  11. Island TraversalPatternTreat a grid as an implicit graph and traverse connected components using directional neighbors.
  12. K-way MergePatternUse a heap of current heads to merge or traverse multiple sorted sequences efficiently.
  13. MemoizationPatternCache top-down subproblem results so overlapping recursive states are solved only once.
  14. Merge IntervalsPatternSort intervals and combine overlapping ranges while tracking the current merged endpoint.
  15. Monotonic QueuePatternMaintain a deque ordered by value to query window extrema while elements enter and leave.
  16. Monotonic StackPatternMaintain ordered unresolved candidates for next-greater, next-smaller, and span problems.
  17. Multi-source BFSPatternSeed a BFS with every starting state to model simultaneous shortest-time propagation.
  18. Opposite-direction PointersPatternMove pointers inward from both ends when ordering lets each comparison discard candidates.
  19. Prefix SumPatternPrecompute cumulative aggregates so range queries become constant-time differences.
  20. Same-direction PointersPatternAdvance read and write pointers in one direction for compaction, partitioning, or deduplication.
  21. Sliding WindowPatternMaintain an incrementally updated contiguous range instead of recomputing every subarray.
  22. State-machine DPPatternRepresent each step with a small set of allowed states and transitions between them.
  23. Sweep LinePatternSort boundary events and process them in order to track active intervals or geometric state.
  24. TabulationPatternOrder bottom-up subproblems so every dependency is available before a state is computed.
  25. Top KPatternKeep only the best k candidates with a heap, quickselect, counting, or bucket strategy.
  26. Tree DPPatternAggregate dynamic-programming states from child subtrees into a result for each parent node.
  27. Two PointersPatternCoordinate two indices to eliminate candidate pairs or partition an ordered search space.
  28. Variable-size WindowPatternExpand and contract a window to preserve a validity invariant and optimize its length or score.
  29. Adjacency ListData structureGraph representation storing each vertex's neighbors with space proportional to vertices and edges.
  30. Adjacency MatrixData structureDense graph representation using a vertex-by-vertex matrix for constant-time edge lookup.
  31. ArrayData structureContiguous indexed sequence used for random access, scanning, and in-place transformations.
  32. Balanced TreeData structureSearch tree that controls height so ordered operations remain logarithmic in the worst case.
  33. Binary Search TreeData structureBinary tree maintaining an ordering invariant for search, insertion, and range traversal.
  34. Binary TreeData structureTree whose nodes have at most two children, enabling standard recursive traversal patterns.
  35. DequeData structureDouble-ended queue supporting constant-time insertion and removal at both ends.
  36. Disjoint Set UnionData structurePartition structure supporting near-constant-time connectivity queries through find and union.
  37. Fenwick TreeData structureCompact indexed tree supporting logarithmic prefix aggregates and point updates.
  38. GraphData structureVertices and edges representing arbitrary relationships, reachability, paths, and dependencies.
  39. Hash MapData structureKey-value structure providing average constant-time lookup, update, and frequency aggregation.
  40. Hash SetData structureUnique-key structure for average constant-time membership and duplicate detection.
  41. HeapData structurePartially ordered tree-backed structure supporting efficient minimum or maximum extraction.
  42. IntervalData structureStart-end pair representing a range for overlap, scheduling, and sweep-line problems.
  43. Linked ListData structureNode sequence connected by references, favoring local insertion over random access.
  44. Matrix / GridData structureTwo-dimensional indexed data commonly treated as rows, columns, or an implicit graph.
  45. Priority QueueData structureAbstract queue that removes the highest-priority item, commonly implemented with a heap.
  46. QueueData structureFirst-in-first-out structure for breadth-first traversal, scheduling, and ordered processing.
  47. Segment TreeData structureRange-query tree supporting logarithmic aggregation and point or lazy range updates.
  48. StackData structureLast-in-first-out structure for nested state, expression evaluation, and iterative traversal.
  49. StringData structureImmutable character sequence used in parsing, matching, sliding-window, and dynamic-programming tasks.
  50. TreeData structureHierarchical acyclic structure used for recursive aggregation, search, and ordered relationships.
  51. TrieData structurePrefix tree for incremental string lookup, autocomplete, and dictionary-constrained search.
  52. A* SearchAlgorithmPrioritize path states by cost-so-far plus an admissible heuristic toward the goal.
  53. BacktrackingAlgorithmEnumerate constrained candidates by choosing, exploring, pruning, and undoing decisions.
  54. Bellman-FordAlgorithmRelax every edge repeatedly to support negative weights and detect reachable negative cycles.
  55. Binary SearchAlgorithmRepeatedly halve an ordered or monotone search space using a boundary invariant.
  56. Bipartite CheckAlgorithmTwo-color graph components with BFS or DFS and reject edges joining equal colors.
  57. Bit ManipulationAlgorithmUse bitwise operations and binary representations for masks, parity, subsets, and compact state.
  58. Breadth-first SearchAlgorithmExplore states level by level, yielding shortest unweighted path lengths from the source set.
  59. Bucket SortAlgorithmDistribute values into ordered buckets, sort locally, and concatenate under distribution assumptions.
  60. Counting SortAlgorithmCount bounded integer keys and reconstruct order in time proportional to input plus key range.
  61. Cycle DetectionAlgorithmDetect repeated reachability state using DFS colors, indegrees, union-find, or fast-slow pointers.
  62. Depth-first SearchAlgorithmExplore a branch completely before backtracking, using recursion or an explicit stack.
  63. DijkstraAlgorithmFind shortest paths with nonnegative weights by greedily finalizing the nearest unsettled vertex.
  64. Divide and ConquerAlgorithmSplit a problem into independent subproblems, solve them recursively, and combine results.
  65. Dynamic ProgrammingAlgorithmSolve overlapping subproblems once and combine their results under a state transition.
  66. Euclidean GCDAlgorithmRepeatedly replace a pair by divisor and remainder to compute the greatest common divisor.
  67. Fisher-Yates ShuffleAlgorithmGenerate an unbiased permutation by swapping each position with a uniformly chosen remaining one.
  68. Floyd-WarshallAlgorithmCompute all-pairs shortest paths by progressively allowing each vertex as an intermediate.
  69. GreedyAlgorithmMake locally optimal choices only when an exchange or invariant proves global correctness.
  70. HashingAlgorithmMap keys to buckets for average constant-time membership, aggregation, and lookup.
  71. Heap SortAlgorithmBuild a heap and repeatedly extract extrema for in-place O(n log n) sorting.
  72. Kadane's AlgorithmAlgorithmTrack the best subarray ending at each position to obtain a linear-time maximum subarray sum.
  73. Kahn's AlgorithmAlgorithmProduce a topological order by repeatedly removing zero-indegree vertices with a queue.
  74. Knuth-Morris-PrattAlgorithmUse a prefix-function fallback table to match strings in linear time without rescanning text.
  75. KruskalAlgorithmBuild a minimum spanning tree by taking sorted edges that join different components.
  76. Linear SearchAlgorithmInspect candidates sequentially when no exploitable ordering or index is available.
  77. Merge SortAlgorithmRecursively sort halves and merge them in stable O(n log n) time with auxiliary storage.
  78. Minimum Spanning TreeAlgorithmConnect every vertex with minimum total edge weight while keeping the result acyclic.
  79. Modular ArithmeticAlgorithmApply congruence rules to keep large integer calculations bounded and preserve equivalence.
  80. PrimAlgorithmGrow a minimum spanning tree by repeatedly choosing the cheapest edge leaving the tree.
  81. Quick SortAlgorithmPartition around pivots and recursively sort partitions with average O(n log n) time.
  82. QuickselectAlgorithmPartition like quicksort while recursing into only the side containing the requested rank.
  83. Rabin-KarpAlgorithmUse a rolling hash to compare many candidate substrings efficiently with collision checks.
  84. Radix SortAlgorithmApply stable digit-wise passes to sort bounded-width keys without direct comparisons.
  85. RecursionAlgorithmSolve a problem by reducing it to smaller instances with explicit base cases.
  86. Reservoir SamplingAlgorithmMaintain an unbiased sample from a stream whose total length is unknown in advance.
  87. SearchAlgorithmLocate a value, state, path, or feasible answer inside an explicit or implicit search space.
  88. Shortest PathAlgorithmCompute minimum path cost under edge-weight assumptions that determine the correct method.
  89. Sieve of EratosthenesAlgorithmMark multiples of discovered primes to enumerate primes up to a fixed bound efficiently.
  90. SortingAlgorithmReorder values by a comparison or key to expose structure for subsequent processing.
  91. String MatchingAlgorithmLocate pattern occurrences in text while controlling repeated comparison work.
  92. Topological SortAlgorithmOrder a directed acyclic graph so every dependency appears before its dependents.
  93. Union-FindAlgorithmMaintain dynamic components using path-compressed find and union by rank or size.

Keep the craft