Skip to content

Add interview pattern guides to six algorithm notes - #32

Merged
djeada merged 2 commits into
masterfrom
notes/leetcode-pattern-guides
Nov 12, 2026
Merged

djeada merged 2 commits into
masterfrom
notes/leetcode-pattern-guides

Conversation

@djeada

@djeada djeada commented Nov 12, 2026

Copy link
Copy Markdown
Owner

This PR makes the notes more useful for someone who is about to solve LeetCode-style problems. Each of the six notes was compared against roughly the 30 most common LeetCode problems in its area, and the patterns that were missing or only mentioned in passing now have their own short sections.

Three kinds of additions appear in every note:

  • A short "First step" box at the top of each major technique. It says what to decide or set up before writing code, for example whether the graph is directed, what the DP state means, or which predicate a binary search is testing.
  • New compact sections for the missing patterns. Each has a short explanation, one small code block, its complexity, and the most common mistake. The matching LeetCode problems are named by number.
  • A "Reading the Problem Statement" table at the end of the note. It translates wording such as "undirected", "connected is not promised", "at most k stops", "order does not matter" or "minimize the maximum" into what it means for the code.

What changed in each note:

  • graphs.md adds common BFS and DFS patterns (multi-source BFS, searching back from the borders, implicit graphs, state BFS, clone graph, leaf peeling, 0-1 BFS), graph coloring, bridges and strongly connected components, standalone Union-Find, minimax and max-probability Dijkstra, Bellman–Ford with at most k edges, Floyd–Warshall and Hierholzer's algorithm.
  • dynamic_programming.md adds linear DP, Kadane, 0/1 versus unbounded knapsack, combinations versus permutations loop order, grid DP, LIS in O(n log n), two-string DP, interval DP, stock state machines, tree DP and bitmask DP.
  • backtracking.md adds the choose/explore/unchoose template, start index versus used array versus reuse, duplicate skipping, Sudoku, grid search, Word Search II with a trie, string partitioning, parentheses, expression building and k-bucket filling.
  • math_set_relationship.md adds subsets as bitmasks, submask enumeration, Gray code, next and k-th permutation, safe binomial coefficients modulo a prime, Catalan numbers, inclusion-exclusion, XOR tricks and hash-set operations.
  • searching.md adds one binary search template with its invariant, lower and upper bound, library bisect, binary search on the answer, rotated arrays, peak finding, 2D matrices, k-th smallest by counting, median of two sorted arrays, and pair lookup with hashing or two pointers.
  • sorting.md adds sort keys and comparators, merging from the back, linked-list merge sort, pair counting with merge sort, Dutch national flag, quickselect, top k with a heap, bucket sort by frequency, interval problems and sorting as preprocessing.

Existing text is kept. The only edit to old content is one sentence in topological sort that implied Kahn's algorithm needs separate cycle detection; it now says Kahn detects cycles through the output count.

All new code blocks were run against brute-force answers on random inputs, and the math passes the website's TeX validator.

🤖 Generated with Claude Code

djeada and others added 2 commits November 12, 2026 15:18
…ing and sorting notes

Each note was checked against the common LeetCode problems in its area.
The missing patterns are now explained in short sections, every major
technique starts with a "First step" box, and each note ends with a
"Reading the Problem Statement" table that maps problem wording to code
decisions. Existing content is kept; one misleading sentence about
cycle detection in the topological sort section was reworded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use \log and \sqrt commands, escape set braces inside display math,
and remove padded dollar delimiters that some renderers skip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@djeada
djeada merged commit 304a4cd into master Nov 12, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant