THN Interview Prep

Pattern Recognition — Keywords to Technique

Triage a problem statement into a pattern bucket, then read the linked pattern note for recipes and templates.

Index: Patterns README


Mermaid flowchart (keyword triage)

Use camelCase node IDs with no spaces. Follow arrows from your best keyword match.

Loading diagram…
BucketPattern guide
TwoPointersTwo pointers
SlidingWindowSliding window
FastSlowFast & slow pointers
BinarySearchBinary search
BFSBFS
DFSDFS / backtracking
HeapTop-K / heap
TopoSortTopological sort
UnionFindUnion-Find
TrieTrie
MonotonicStackMonotonic stack
PrefixSumPrefix sum
BitBit manipulation
DPDynamic programming
GreedyGreedy
DivideConquerDivide & conquer

Related patterns not shown as graph terminals: Merge intervals, Cyclic sort, Linked list reversal, Tree DFS.


Text decision tree (backup)

  1. Input sorted / orderable to sorted

    • Pair / triplet / merge walks → Two Pointers (01).
    • “Smallest X such that …” / boundary on predicate → Binary Search (04).
  2. Contiguous substring/subarray with a constraint (longest/shortest/fixed)
    Sliding Window (02).

  3. Linked list: cycle, middle, k-from-end
    Fast & Slow (03); reversal variants → 10.

  4. Graph / tree

    • Unweighted shortest path / levels → BFS (05).
    • All arrangements / paths / “try combinations” → DFS / backtracking (06).
    • Tree DP / paths → Tree DFS (11).
  5. Top-k, streaming median, Dijkstra frontier
    Heap (07).

  6. Prerequisites / course schedule / build order
    Topological sort (12).

  7. Dynamic connectivity / redundant connection / Kruskal-like
    Union-Find (13).

  8. Prefix search / dictionary / autocomplete on strings
    Trie (14).

  9. “Next greater / smaller element”, histogram, temperature stack
    Monotonic stack (15).

  10. Static range sums / difference-array style updates
    Prefix sum / difference (16).

  11. XOR uniqueness, subset enumeration with bitmask
    Bit manipulation (17).

  12. Overlapping subproblems + optimal substructure
    → often DP (18); Greedy (19) when exchange argument holds; Divide & conquer (20) when subproblems are independent halves.


Cheatsheet peers: Big-O complexity, Data structure operations.

Last updated on

Spotted something unclear or wrong on this page?

On this page