THN Interview Prep

Similar-Problems Cross-Link Map

Auto-generated by scripts/regenerate_similar_problems_map.py. Each row lists pattern, difficulty, similar-problem links (from ## Similar Problems), and mind-map tags. Re-run scripts/refresh-knowledgebase.sh after adding or editing problem mind-maps. Canonical problem locations follow the Problem index.

#ProblemPatternDifficultySimilar (excerpt)Tags
11921192. Critical Connections in a NetworkTarjan bridge finding (DFS lowlink)Hard261:../../graphs/problems/261-graph-valid-tree.md; 684:../../graphs/problems/684-redundant-connection.md; 685:./685-redundant-connection-ii.md#tarjan #bridge #lowlink #dfs #undirected-graph #cut-edge
13341334. Find the City With the Smallest Number of Neighbors at a ThreshoFloyd-Warshall / all-pairs shortest paths (APSP on small n) or repeated DijkstraMedium743:../../graphs/problems/743-network-delay-time.md; 787:../../graphs/problems/787-cheapest-flights-within-k-stops.md; 847:./847-shortest-path-visiting-all-nodes.md#floyd-warshall #all-pairs-shortest-path #threshold-count #tie-break
16311631. Path With Minimum EffortDijkstra minimax on grid + heap; alternative binary search + BFSHard778:../../graphs/problems/778-swim-in-rising-water.md; 743:../../graphs/problems/743-network-delay-time.md; 329:../../dp-2d/problems/329-longest-increasing-path-in-a-matrix.md#dijkstra #minimax #grid #binary-search-on-answer #absolute-difference-edge
685685. Redundant Connection IIUnion-Find + directed-tree case analysisHard684:../../graphs/problems/684-redundant-connection.md; 261:../../graphs/problems/261-graph-valid-tree.md; 1192:./1192-critical-connections.md#union-find #directed-tree #two-parents #cycle-detection #case-analysis
802802. Find Eventual Safe StatesTopological sort on reverse graph or DFS three-color cycle detectionHard207:../../graphs/problems/207-course-schedule.md; 210:../../graphs/problems/210-course-schedule-ii.md; 685:./685-redundant-connection-ii.md#reverse-topo #outdegree-peel #safe-states #directed-acyclic-condensation
815815. Bus RoutesBFS on compressed graph (routes as nodes)Hard743:../../graphs/problems/743-network-delay-time.md; 994:../../graphs/problems/994-rotting-oranges.md; 847:./847-shortest-path-visiting-all-nodes.md#bfs #route-compression #multi-source #stop-to-route-index #layered-bfs
847847. Shortest Path Visiting All NodesBFS on (visitedMask, lastNode) state graph — Traveling Salesman / Held–Karp bitmaskHard994:../../graphs/problems/994-rotting-oranges.md; 815:./815-bus-routes.md; 329:../../dp-2d/problems/329-longest-increasing-path-in-a-matrix.md#bfs #bitmask #tsp-walk #multi-source #state-space-shortest-path
924924. Minimize Malware SpreadUnion-Find component analysis + counting / tie-breakingHard547:../../graphs/problems/547-number-of-provinces.md; 684:../../graphs/problems/684-redundant-connection.md; 1192:./1192-critical-connections.md#union-find #component-count #malware #tie-break #greedy-on-components
11. Two SumHash Map LookupEasy167:../../two-pointers/problems/167-two-sum-ii.md; 242:./242-valid-anagram.md; 217:./217-contains-duplicate.md#hashmap #arrays #two-sum #complement-lookup #indices
2626. Remove Duplicates from Sorted ArrayTwo PointersEasy027:./027-remove-element.md; 088:./088-merge-sorted-array.md; 283:../../two-pointers/problems/283-move-zeroes.md#two-pointers #sorted #dedupe #in-place
2727. Remove ElementTwo PointersEasy026:./026-remove-duplicates-from-sorted-array.md; 283:../../two-pointers/problems/283-move-zeroes.md; 088:./088-merge-sorted-array.md#two-pointers #in-place #filter #arrays
3636. Valid SudokuHash Set per Row/Col/BoxMedium128:./128-longest-consecutive-sequence.md; 217:./217-contains-duplicate.md; 048:./048-rotate-image.md#matrix #hashset #sudoku #grid-indexing #validation
4848. Rotate ImageTranspose + reverse rows (90° clockwise)Medium054:./054-spiral-matrix.md; 189:./189-rotate-array.md; 036:./036-valid-sudoku.md#matrix #transpose #reverse #in-place #geometry
4949. Group AnagramsHash Map BucketingMedium242:./242-valid-anagram.md; 001:./001-two-sum.md; 217:./217-contains-duplicate.md#hashmap #strings #anagram #bucketing #canonical-key
5353. Maximum SubarrayKadane (DP-1D)Medium152:../../dp-1d/problems/152-maximum-product-subarray.md; 121:./121-best-time-to-buy-sell-stock.md; 238:./238-product-of-array-except-self.md#kadane #dp #subarray #prefix-state #greedy-choice
5454. Spiral MatrixLayered traversalMedium048:./048-rotate-image.md; 036:./036-valid-sudoku.md; 189:./189-rotate-array.md#matrix #spiral #layer #boundaries #simulation
8888. Merge Sorted ArrayTwo Pointers (in-place, fill from end)Easy026:./026-remove-duplicates-from-sorted-array.md; 167:../../two-pointers/problems/167-two-sum-ii.md; 21:../../linked-list/problems/021-merge-two-sorted-lists.md#two-pointers #merge #in-place #sorted #arrays
121121. Best Time to Buy and Sell StockOne pass minimum (single transaction)Easy122:./122-best-time-to-buy-sell-stock-ii.md; 053:./053-maximum-subarray.md; 189:./189-rotate-array.md#arrays #greedy #min-so-far #profit #one-pass
122122. Best Time to Buy and Sell Stock IIGreedy (accumulate positive daily deltas)Medium121:./121-best-time-to-buy-sell-stock.md; 053:./053-maximum-subarray.md; 189:./189-rotate-array.md#greedy #arrays #stock #adjacent-delta #accumulation
128128. Longest Consecutive SequenceHash Set SequenceMedium217:./217-contains-duplicate.md; 001:./001-two-sum.md; 049:./049-group-anagrams.md#hashset #sequence #on-time #integers #chain-start
169169. Majority ElementBoyer–Moore votingEasy053:./053-maximum-subarray.md; 217:./217-contains-duplicate.md; 001:./001-two-sum.md#boyer-moore #majority #linear #constant-space #voting
189189. Rotate ArrayReverse trick (triple reverse)Medium048:./048-rotate-image.md; 054:./054-spiral-matrix.md; 088:./088-merge-sorted-array.md#arrays #reverse #in-place #rotation #modular-index
217217. Contains DuplicateHash SetEasy001:./001-two-sum.md; 128:./128-longest-consecutive-sequence.md; 242:./242-valid-anagram.md#hashset #arrays #duplicate-detection #membership
238238. Product of Array Except SelfPrefix Sum / Suffix (prefix–suffix products)Medium152:../../dp-1d/problems/152-maximum-product-subarray.md; 053:./053-maximum-subarray.md; 121:./121-best-time-to-buy-sell-stock.md#arrays #prefix-sum #suffix #product #linear
242242. Valid AnagramHash Map CountingEasy049:./049-group-anagrams.md; 217:./217-contains-duplicate.md; 001:./001-two-sum.md#hashmap #strings #anagram #frequency #counting
271271. Encode and Decode StringsString EncodingMedium238:./238-product-of-array-except-self.md; 242:./242-valid-anagram.md; 394:../../stack/problems/394-decode-string.md#strings #encoding #length-prefix #serialization #design
347347. Top K Frequent ElementsTop-K / Heap (bucket sort variant)Medium215:../../heap-priority-queue/problems/215-kth-largest-element-in-array.md; 238:./238-product-of-array-except-self.md; 001:./001-two-sum.md#heap #bucket-sort #frequency #hashmap #top-k
1717. Letter Combinations of a Phone NumberDFS / BacktrackingMedium46:./046-permutations.md; 78:./078-subsets.md#backtracking #string #cartesian #phone #dfs
3939. Combination SumDFS / BacktrackingMedium40:./040-combination-sum-ii.md; 78:./078-subsets.md; 322:../../dp-1d/problems/322-coin-change.md#backtracking #combination #dfs #reuse-allowed #sorted-start-index
4040. Combination Sum IIDFS / BacktrackingMedium39:./039-combination-sum.md; 90:./090-subsets-ii.md#backtracking #dedupe #sort #combination #target-sum
4646. PermutationsDFS / BacktrackingMedium78:./078-subsets.md; 79:./079-word-search.md; 90:./090-subsets-ii.md#backtracking #permutation #visited-array #factorial-output
051051. N-QueensDFS / Backtracking (also bit-pruning variant: Bit Manipulation)Hard46:./046-permutations.md; 79:./079-word-search.md; 36:../../arrays-hashing/problems/036-valid-sudoku.md#backtracking #chess #diagonals #constraint-pruning #bitmasks-optional #exhaustive-search
7878. SubsetsDFS / BacktrackingMedium90:./090-subsets-ii.md; 46:./046-permutations.md#backtracking #subsets #power-set #dfs #recursion
7979. Word SearchDFS / BacktrackingMedium46:./046-permutations.md; 131:./131-palindrome-partitioning.md#dfs #grid #backtracking #path #string
9090. Subsets IIDFS / BacktrackingMedium78:./078-subsets.md; 40:./040-combination-sum-ii.md#backtracking #subsets #dedupe #sort #dfs
131131. Palindrome PartitioningDFS / BacktrackingMedium39:./039-combination-sum.md; 079:./079-word-search.md#backtracking #palindrome #string #partition #dfs
698698. Partition to K Equal Sum SubsetsDFS / BacktrackingMedium39:./039-combination-sum.md; 40:./040-combination-sum-ii.md; 416:../../dp-1d/problems/416-partition-equal-subset-sum.md#backtracking #bucket-fill #pruning #sort-desc #bitmask-optional
004004. Median of Two Sorted ArraysBinary Search (partition the two arrays)Hard704:./704-binary-search.md; 35:./035-search-insert-position.md; 410:./410-split-array-largest-sum.md#binary-search #partition #median #two-arrays #log-min #sentinel
3333. Search in Rotated Sorted ArrayBinary Search (Rotated, two ascents)Medium153:./153-find-min-in-rotated-sorted-array.md; 704:./704-binary-search.md; 35:./035-search-insert-position.md#binary-search #rotated-array #sorted-half-invariant #target-range
3535. Search Insert PositionBinary Search (Lower bound)Easy704:./704-binary-search.md; 74:./074-search-a-2d-matrix.md; 33:./033-search-in-rotated-sorted-array.md#binary-search #lower-bound #sorted-array #half-open-interval
7474. Search a 2D MatrixBinary Search (Implicit 1D order)Medium704:./704-binary-search.md; 35:./035-search-insert-position.md; 875:./875-koko-eating-bananas.md#binary-search #matrix #row-major #implicit-sorted-array
10111011. Capacity to Ship Packages Within D DaysBinary Search (Search on answer)Medium875:./875-koko-eating-bananas.md; 704:./704-binary-search.md; 35:./035-search-insert-position.md#binary-search #search-on-answer #greedy-feasibility #partition-days
153153. Find Minimum in Rotated Sorted ArrayBinary Search (Rotation / pivot)Medium33:./033-search-in-rotated-sorted-array.md; 162:./162-find-peak-element.md; 704:./704-binary-search.md#binary-search #rotated-array #pivot #compare-to-right
162162. Find Peak ElementBinary Search (Slope / neighbor compare)Medium153:./153-find-min-in-rotated-sorted-array.md; 704:./704-binary-search.md; 875:./875-koko-eating-bananas.md#binary-search #peak #slope #neighbor-compare
410410. Split Array Largest SumBinary Search on answer (feasibility check)Hard1011:./1011-capacity-to-ship-packages-in-d-days.md; 875:./875-koko-eating-bananas.md; 4:./004-median-of-two-sorted-arrays.md#binary-search-on-answer #minimize-maximum #greedy-feasibility #contiguous-split #hard-classic
540540. Single Element in a Sorted ArrayBinary Search (Pair invariant)Medium704:./704-binary-search.md; 136:../../bit-manipulation/problems/136-single-number.md; 153:./153-find-min-in-rotated-sorted-array.md#binary-search #pairs #even-index-invariant #sorted-structure
704704. Binary SearchBinary Search (Vanilla)Easy35:./035-search-insert-position.md; 74:./074-search-a-2d-matrix.md; 33:./033-search-in-rotated-sorted-array.md#binary-search #sorted-array #log-n #two-end-window
875875. Koko Eating BananasBinary Search (Search on answer)Medium1011:./1011-capacity-to-ship-packages-in-d-days.md; 704:./704-binary-search.md; 35:./035-search-insert-position.md#binary-search #search-on-answer #monotone-feasible #ceil-sum
981981. Time Based Key-Value StoreBinary Search (Prefix / latest ≤ timestamp)Medium35:./035-search-insert-position.md; 704:./704-binary-search.md; 875:./875-koko-eating-bananas.md#binary-search #time-series #prefix-max #map-of-vectors
136136. Single NumberXOR cancelation (Bit Manipulation)Easy268:./268-missing-number.md; 137:./137-single-number-ii.md#xor #cancel-pairs #bit-manipulation #linear-scan
137137. Single Number IIBit count modulo 3 (Bit Manipulation)Medium136:./136-single-number.md; 268:./268-missing-number.md#mod-3 #bits #finite-state #xor-generalization #single-number
190190. Reverse BitsBit ops / shift accumulate (Bit Manipulation)Easy191:./191-number-of-1-bits.md; 007:../../math-geometry/problems/007-reverse-integer.md#reverse-bits #shift #unsigned #fixed-width #bit-ops
191191. Number of 1 BitsBrian Kernighan trick (Bit Manipulation)Easy338:./338-counting-bits.md; 190:./190-reverse-bits.md#popcount #brian-kernighan #lowest-set-bit #bit-tricks
268268. Missing NumberXOR / Gauss sum (Bit Manipulation)Easy136:./136-single-number.md; 338:./338-counting-bits.md#xor #missing-value #index-match #range-0-n #linear
338338. Counting BitsDP + bit relation (Bit Manipulation)Easy191:./191-number-of-1-bits.md; 268:./268-missing-number.md#dp #popcount #bit-relation #prefix-table #on
371371. Sum of Two IntegersBitwise full adder (Bit Manipulation)Medium136:./136-single-number.md; 191:./191-number-of-1-bits.md#full-adder #xor #carry #ripple #bit-manipulation
55. Longest Palindromic SubstringDynamic Programming and/or expand around center; Two Pointers for expandMedium647:./647-palindromic-substrings.md; 1143:../../dp-2d/problems/1143-longest-common-subsequence.md; 091:./091-decode-ways.md#dp-2d-on-string #palindrome #expand-center #medium
3232. Longest Valid ParenthesesDynamic Programming + Monotonic StackHard20:../../stack/problems/020-valid-parentheses.md; 22:../../stack/problems/022-generate-parentheses.md; 84:../../stack/problems/084-largest-rectangle-in-histogram.md#parentheses #monotonic-stack #sentinel-index #o-n-one-pass #span-length
7070. Climbing StairsDynamic Programming (Fibonacci-style linear recurrence)Easy746:./746-min-cost-climbing-stairs.md; 198:./198-house-robber.md; 322:./322-coin-change.md#dp-1d #linear-dp #fibonacci #rolling-state #easy
9191. Decode WaysDynamic Programming (string digit partition)Medium139:./139-word-break.md; 322:./322-coin-change.md#dp-1d #string-dp #digit-partition #rolling-state #medium
132132. Palindrome Partitioning IIDynamic Programming — prefix min cuts + palindrome preprocessingHard131:../../backtracking/problems/131-palindrome-partitioning.md; 5:./005-longest-palindromic-substring.md; 32:./032-longest-valid-parentheses.md#palindrome-dp #prefix-dp #minimum-cuts #interval-table #o-n-squared
139139. Word BreakDynamic Programming on string segmentation; Trie for dictionary lookup / pruningMedium091:./091-decode-ways.md; 322:./322-coin-change.md; 300:./300-longest-increasing-subsequence.md#word-break #trie-optional #segmentation-dp #dictionary #medium
152152. Maximum Product SubarrayDynamic Programming (track min and max along line)Medium53:../../arrays-hashing/problems/053-maximum-subarray.md; 238:../../arrays-hashing/problems/238-product-of-array-except-self.md; 322:./322-coin-change.md#kadane-variant #product #min-max-dp #dp-1d #medium
198198. House RobberDynamic Programming (take-or-skip on a line)Medium213:./213-house-robber-ii.md; 746:./746-min-cost-climbing-stairs.md; 070:./070-climbing-stairs.md#dp-1d #take-or-skip #linear-dp #rolling-state #medium
213213. House Robber IIDynamic Programming (circular array reduction)Medium198:./198-house-robber.md; 070:./070-climbing-stairs.md; 300:./300-longest-increasing-subsequence.md#dp-1d #circular-array #house-robber #two-pass #medium
300300. Longest Increasing SubsequenceDynamic Programming (O(n^2)); patience sorting + binary search (O(n log n))Medium322:./322-coin-change.md; 416:./416-partition-equal-subset-sum.md; 1143:../../dp-2d/problems/1143-longest-common-subsequence.md#lis #patience-sorting #binary-search-on-answer #dp-1d #medium
322322. Coin ChangeDynamic Programming (unbounded knapsack: minimum count)Medium518:../../dp-2d/problems/518-coin-change-2.md; 494:../../dp-2d/problems/494-target-sum.md#unbounded-knapsack #coin-change #min-coins #dp-1d #medium
416416. Partition Equal Subset SumDynamic Programming (0/1 knapsack reachability)Medium494:../../dp-2d/problems/494-target-sum.md; 322:./322-coin-change.md#01-knapsack #subset-sum #partition #boolean-dp #medium
647647. Palindromic SubstringsDynamic Programming (string palindromes) / expand around centerMedium5:./005-longest-palindromic-substring.md; 091:./091-decode-ways.md; 300:./300-longest-increasing-subsequence.md#palindrome #expand-center #string-dp #counting #medium
746746. Min Cost Climbing StairsDynamic Programming (linear minimum cost)Easy70:./070-climbing-stairs.md; 198:./198-house-robber.md#dp-1d #linear-dp #min-cost-path #rolling-state #easy
1010. Regular Expression MatchingDynamic Programming — string vs pattern (with * Kleene on prior atom)Hard72:./072-edit-distance.md; 97:./097-interleaving-string.md; 115:./115-distinct-subsequences.md#regex-dp #kleene-star #dot-wildcard #prefix-match #boolean-table
6262. Unique PathsDynamic Programming (grid paths)Medium63:./063-unique-paths-ii.md; 1143:./1143-longest-common-subsequence.md; 097:./097-interleaving-string.md#grid-dp #combinatorics #path-count #rolling-row #medium
6363. Unique Paths IIDynamic Programming (grid with obstacles)Medium62:./062-unique-paths.md; 322:../../dp-1d/problems/322-coin-change.md; 518:./518-coin-change-2.md#grid-dp #obstacles #rolling-row #medium
7272. Edit DistanceDynamic Programming — two stringsHard1143:./1143-longest-common-subsequence.md; 97:./097-interleaving-string.md; 115:./115-distinct-subsequences.md#levenshtein #two-string-dp #rolling-array #string-alignment #minimum-ops
9797. Interleaving StringDynamic Programming (two-string matching with merge order)Medium1143:./1143-longest-common-subsequence.md; 62:./062-unique-paths.md#2d-dp #interleaving #two-strings #medium
11431143. Longest Common SubsequenceDynamic Programming (2D string/table LCS)Medium300:../../dp-1d/problems/300-longest-increasing-subsequence.md; 097:./097-interleaving-string.md#lcs #2d-dp #string-dp #rolling-two-rows #medium
115115. Distinct SubsequencesDynamic Programming — two-sequence (count ways to match subsequence)Hard1143:./1143-longest-common-subsequence.md; 72:./072-edit-distance.md; 10:./010-regular-expression-matching.md#two-string-dp #subsequence-count #rolling-array #modulo #reverse-inner-loop
174174. Dungeon GameDynamic Programming — reverse reachability / min initial resourceHard62:./062-unique-paths.md; 329:./329-longest-increasing-path-in-a-matrix.md; 312:./312-burst-balloons.md#grid-dp #reverse-dp #min-initial-resource #survival #clamp-positive
309309. Best Time to Buy and Sell Stock with CooldownDynamic Programming (finite state machine on timeline)Medium121:../../arrays-hashing/problems/121-best-time-to-buy-sell-stock.md; 122:../../arrays-hashing/problems/122-best-time-to-buy-sell-stock-ii.md; 416:../../dp-1d/problems/416-partition-equal-subset-sum.m#stock-dp #state-machine #cooldown #medium
312312. Burst BalloonsInterval DP (optimal subarray removal / matrix chain style)Hard131:../../backtracking/problems/131-palindrome-partitioning.md; 1143:./1143-longest-common-subsequence.md; 887:./887-super-egg-drop.md#interval-dp #last-element-split #matrix-chain #pad-sentinel #maximize-coins
329329. Longest Increasing Path in a MatrixDFS + memoization on DAG (implicit graph from strict increase) + Dynamic ProgrammingHard62:./062-unique-paths.md; 300:../../dp-1d/problems/300-longest-increasing-subsequence.md; 847:../../advanced-graphs/problems/847-shortest-path-visiting-all-nodes.md#grid-dp #dag-longest-path #dfs-memo #strictly-increasing #implicit-graph
494494. Target SumDynamic Programming (subset sum / knapsack reformulation)Medium416:../../dp-1d/problems/416-partition-equal-subset-sum.md; 518:./518-coin-change-2.md#subset-sum #sign-assignment #01-knapsack-count #medium
518518. Coin Change 2Dynamic Programming (unbounded knapsack: count ways)Medium322:../../dp-1d/problems/322-coin-change.md; 494:./494-target-sum.md#unbounded-knapsack #combinations #coin-change-2 #medium
887887. Super Egg DropDynamic Programming + binary search on answeregg-drop / DP over movesHard312:./312-burst-balloons.md; 410:../../binary-search/problems/410-split-array-largest-sum.md; 174:./174-dungeon-game.md#egg-drop #minimax #dp-on-moves #reverse-state-count #binary-search-floor
127127. Word LadderBFS / shortest path on implicit graphHard994:./994-rotting-oranges.md; 200:./200-number-of-islands.md; 778:./778-swim-in-rising-water.md#bfs #implicit-graph #shortest-path #string-transform #layered-search
130130. Surrounded RegionsDFS / BacktrackingMedium200:./200-number-of-islands.md; 417:./417-pacific-atlantic-water-flow.md#grid #dfs #boundary #flood-fill #in-place
133133. Clone GraphDFS / Backtracking + hash mapMedium200:./200-number-of-islands.md; 261:./261-graph-valid-tree.md; 138:../../linked-list/problems/138-copy-list-with-random-pointer.md#graph #clone #hashmap #dfs #bfs #undirected
15841584. Min Cost to Connect All PointsMST — Prim / Kruskal (shortest-path / spanning-tree family)Medium743:./743-network-delay-time.md; 684:./684-redundant-connection.md#mst #prim #manhattan #complete-graph #greedy
19761976. Number of Ways to Arrive at DestinationDijkstra + counting (shortest-path family)Medium743:./743-network-delay-time.md; 787:./787-cheapest-flights-within-k-stops.md#dijkstra #counting #shortest-path #modulo #undirected
200200. Number of IslandsDFS / Backtracking (grid DFS) / BFS / Union-FindMedium695:./695-max-area-of-island.md; 547:./547-number-of-provinces.md#grid #dfs #flood-fill #connected-components #graphs
207207. Course ScheduleTopological SortMedium210:./210-course-schedule-ii.md; 269:./269-alien-dictionary.md; 802:../../advanced-graphs/problems/802-find-eventual-safe-states.md#topological-sort #kahn #dfs-cycle #directed-graph #prerequisites
210210. Course Schedule IITopological SortMedium207:./207-course-schedule.md; 269:./269-alien-dictionary.md; 329:../../dp-2d/problems/329-longest-increasing-path-in-a-matrix.md#topological-sort #kahn #ordering #bfs-level #course-plan
261261. Graph Valid TreeUnion-Find or DFS connectivityMedium323:./323-number-of-connected-components.md; 684:./684-redundant-connection.md#union-find #tree #cycle #connectivity #edges-count
269269. Alien DictionaryTopological sort on a character graph inferred from adjacent wordsHard207:./207-course-schedule.md; 210:./210-course-schedule-ii.md; 329:../../dp-2d/problems/329-longest-increasing-path-in-a-matrix.md#topological-sort #character-graph #indegree #kahn-bfs #invalid-prefix-check
286286. Walls and GatesBFS (multi-source shortest path on grid)Medium994:./994-rotting-oranges.md; 743:./743-network-delay-time.md#bfs #multi-source #grid #shortest-distance #in-place
305305. Number of Islands IIUnion-Find (dynamic connectivity) on a sparse gridHard200:./200-number-of-islands.md; 323:./323-number-of-connected-components.md; 684:./684-redundant-connection.md#union-find #dynamic-connectivity #grid-dsu #online-query #component-count
323323. Number of Connected Components in an Undirected GraphUnion-Find or DFS/BFSMedium547:./547-number-of-provinces.md; 261:./261-graph-valid-tree.md#union-find #components #undirected #connectivity
332332. Reconstruct ItineraryHierholzer’s algorithm (Eulerian circuit / trail) with DFS postorderHard207:./207-course-schedule.md; 269:./269-alien-dictionary.md; 210:./210-course-schedule-ii.md#eulerian-trail #hierholzer #dfs-postorder #lexicographic #directed-multigraph
417417. Pacific Atlantic Water FlowDFS / Backtracking (multi-source)Medium200:./200-number-of-islands.md; 286:./286-walls-and-gates.md#grid #dfs #multi-source #reverse-flow #matrix
547547. Number of ProvincesUnion-Find or DFS on adjacency matrixMedium323:./323-number-of-connected-components.md; 200:./200-number-of-islands.md#dfs #adjacency-matrix #components #undirected
684684. Redundant ConnectionUnion-FindMedium261:./261-graph-valid-tree.md; 323:./323-number-of-connected-components.md#union-find #cycle #undirected #tree-plus-edge
695695. Max Area of IslandDFS / BacktrackingMedium200:./200-number-of-islands.md; 417:./417-pacific-atlantic-water-flow.md#grid #dfs #area #connected-component
743743. Network Delay TimeDijkstra shortest path (BFS family / weighted routing)Medium787:./787-cheapest-flights-within-k-stops.md; 1976:./1976-number-of-ways-to-arrive-at-destination.md#dijkstra #shortest-path #heap #directed #weighted
778778. Swim in Rising WaterDijkstra / “minimize max edge” (path threshold) with min-heapHard743:./743-network-delay-time.md; 1631:../../advanced-graphs/problems/1631-path-with-minimum-effort.md; 127:./127-word-ladder.md#dijkstra #minimax-path #grid-graph #priority-queue #binary-search-on-answer
787787. Cheapest Flights Within K StopsBellman-Ford / layered relaxation (shortest-path family)Medium743:./743-network-delay-time.md; 1976:./1976-number-of-ways-to-arrive-at-destination.md#bellman-ford #layered-relaxation #flights #shortest-path
994994. Rotting OrangesBFS (multi-source, layered)Medium286:./286-walls-and-gates.md; 200:./200-number-of-islands.md#bfs #multi-source #grid #level-order #shortest-time
4545. Jump Game IIGreedy (level-wise farthest reach / BFS-like)Medium55:./055-jump-game.md; 056:./056-merge-intervals.md; 134:./134-gas-station.md#greedy #minimum-jumps #layered-bfs #medium
5555. Jump GameGreedy (reach farthest index)Medium45:./045-jump-game-ii.md; 056:./056-merge-intervals.md; 134:./134-gas-station.md#greedy #reachability #farthest-index #medium
5656. Merge IntervalsMerge Intervals (sort by start, linear merge)Medium435:./435-non-overlapping-intervals.md; 057:../../intervals/problems/057-insert-interval.md#merge-intervals #sort #sweep-line #medium
134134. Gas StationGreedy (single pass with restart)Medium53:../../arrays-hashing/problems/053-maximum-subarray.md; 763:./763-partition-labels.md; 55:./055-jump-game.md#greedy #circular-array #tank-balance #medium
18991899. Merge Triplets to Form TargetGreedy (coordinate-wise feasibility filter)Medium056:./056-merge-intervals.md; 435:./435-non-overlapping-intervals.md; 763:./763-partition-labels.md#greedy #coordinate-max #filter #medium
435435. Non-overlapping IntervalsGreedy on intervals (pick earliest ending)Medium056:./056-merge-intervals.md; 253:../../intervals/problems/253-meeting-rooms-ii.md; 252:../../intervals/problems/252-meeting-rooms.md#intervals #greedy #activity-selection #medium
678678. Valid Parenthesis StringGreedy (balance range) / stack variantMedium20:../../stack/problems/020-valid-parentheses.md; 763:./763-partition-labels.md; 055:./055-jump-game.md#greedy #parentheses #wildcard #balance-range #medium
763763. Partition LabelsGreedy (scan + last occurrence map)Medium056:./056-merge-intervals.md; 435:./435-non-overlapping-intervals.md; 1899:./1899-merge-triplets-to-form-target.md#greedy #last-occurrence #string-partition #medium
846846. Hand of StraightsGreedy with ordered frequency mapMedium056:./056-merge-intervals.md; 435:./435-non-overlapping-intervals.md; 045:./045-jump-game-ii.md#greedy #frequency-map #consecutive-groups #medium
10461046. Last Stone WeightTop-K / Heap (max-heap)Easy703:./703-kth-largest-in-stream.md; 215:./215-kth-largest-element-in-array.md#heap #max-heap #simulation #greedy #two-largest
18341834. Single-Threaded CPUTop-K / Heap (by processing time) + orderingMedium621:./621-task-scheduler.md; 355:./355-design-twitter.md#heap #scheduling #simulation #time-advance #greedy
215215. Kth Largest Element in an ArrayTop-K / HeapMedium703:./703-kth-largest-in-stream.md; 973:./973-k-closest-points-to-origin.md#heap #quickselect #top-k #kth-largest #min-heap
295295. Find Median from Data StreamTop-K / Heap (two heaps)Hard703:./703-kth-largest-in-stream.md; 215:./215-kth-largest-element-in-array.md; 502:./502-ipo.md; 632:./632-smallest-range-covering-k-lists.md#two-heaps #median #streaming #heap-balance #order-statistics #hard-design
355355. Design TwitterTop-K / Heap + hash mapsMedium973:./973-k-closest-points-to-origin.md; 1834:./1834-single-threaded-cpu.md; 295:./295-find-median-from-data-stream.md#design #heap #merge-k-streams #timestamp #social-graph
502502. IPOTop-K / Heap (greedy + max-heap of profits)Hard621:./621-task-scheduler.md; 215:./215-kth-largest-element-in-array.md; 295:./295-find-median-from-data-stream.md; 632:./632-smallest-range-covering-k-lists.md#heap #greedy #sort-by-capital #k-rounds #maximize-capital #feasible-set
621621. Task SchedulerTop-K / Heap (simulation) + greedy layoutMedium1046:./1046-last-stone-weight.md; 1834:./1834-single-threaded-cpu.md#greedy #cooldown #frequency #math #heap-alternative
632632. Smallest Range Covering Elements from K ListsTop-K / Heap (k-way min tracking + global max) with Sliding Window-style pointer advanceHard21:../../linked-list/problems/021-merge-two-sorted-lists.md; 215:./215-kth-largest-element-in-array.md; 23:../../linked-list/problems/023-merge-k-sorted-lists.md#k-way-merge #min-heap #running-max #sorted-lists #smallest-range #greedy-advance-min
703703. Kth Largest Element in a StreamTop-K / HeapEasy215:./215-kth-largest-element-in-array.md; 973:./973-k-closest-points-to-origin.md#heap #min-heap #top-k #streaming #kth-largest #container-heap
973973. K Closest Points to OriginTop-K / HeapMedium215:./215-kth-largest-element-in-array.md; 703:./703-kth-largest-in-stream.md#heap #max-heap-size-k #geometry #euclidean #top-k-smallest
5757. Insert IntervalMerge IntervalsMedium56:../../greedy/problems/056-merge-intervals.md; 253:./253-meeting-rooms-ii.md#merge-intervals #insert #sweep #medium
18511851. Minimum Interval to Include Each QuerySort + sweep + Min-heap (offline queries)Hard253:./253-meeting-rooms-ii.md; 218:./218-the-skyline-problem.md; 57:./057-insert-interval.md; 56:../../greedy/problems/056-merge-intervals.md#offline-queries #interval-sweep #min-heap #sort-by-start #stale-pop
218218. The Skyline ProblemSweep line + Heap / multiset (active heights)Hard1851:./1851-min-interval-to-include-each-query.md; 253:./253-meeting-rooms-ii.md; 57:./057-insert-interval.md#skyline #sweep-line #multiset-heights #edge-events #critical-points
252252. Meeting RoomsMerge Intervals (sort + pairwise check)Easy253:./253-meeting-rooms-ii.md; 435:../../greedy/problems/435-non-overlapping-intervals.md#intervals #sort #overlap-check #easy
253253. Meeting Rooms IITop-K / Heap (min-heap of end times) on timelineMedium252:./252-meeting-rooms.md; 435:../../greedy/problems/435-non-overlapping-intervals.md#heap #meeting-rooms #sweep-time #medium
986986. Interval List IntersectionsTwo Pointers on sorted interval listsMedium56:../../greedy/problems/056-merge-intervals.md; 252:./252-meeting-rooms.md; 57:./057-insert-interval.md#two-pointers #interval-intersection #sorted-lists #medium
22. Add Two NumbersLinked-list arithmetic (digit-wise with carry)Medium21:./021-merge-two-sorted-lists.md; 138:./138-copy-list-with-random-pointer.md; 19:./019-remove-nth-from-end.md#linked-list #carry #dummy-tail #school-addition
1919. Remove Nth Node From End of ListFast & Slow Pointers (gap / offset)Medium141:./141-linked-list-cycle.md; 143:./143-reorder-list.md; 206:./206-reverse-linked-list.md#linked-list #two-pointer #dummy-head #nth-from-end
2121. Merge Two Sorted ListsMerge (sorted streams)Easy88:../../arrays-hashing/problems/088-merge-sorted-array.md; 143:./143-reorder-list.md; 206:./206-reverse-linked-list.md#linked-list #merge #two-sorted #dummy-node
023023. Merge K Sorted ListsTop-K / Heap or Divide & ConquerHard21:./021-merge-two-sorted-lists.md; 206:./206-reverse-linked-list.md; 25:./025-reverse-nodes-in-k-group.md#k-way-merge #min-heap #divide-conquer #linked-list #multilist #hard-classic
025025. Reverse Nodes in k-GroupIn-place Linked List ReversalHard206:./206-reverse-linked-list.md; 92:./092-reverse-linked-list-ii.md; 23:./023-merge-k-sorted-lists.md#linked-list #reverse-range #k-group #dummy-node #in-place #hard-pointer
9292. Reverse Linked List IIIn-place Linked List Reversal (Subrange)Medium206:./206-reverse-linked-list.md; 143:./143-reorder-list.md; 234:./234-palindrome-linked-list.md#linked-list #sublist-reverse #dummy-anchor #insert-front
138138. Copy List with Random PointerHash map / interleaving cloneMedium133:../../graphs/problems/133-clone-graph.md; 21:./021-merge-two-sorted-lists.md; 143:./143-reorder-list.md#linked-list #deep-copy #random-pointer #interleave-unzip
141141. Linked List CycleFast & Slow Pointers (Floyd’s cycle)Easy142:./142-linked-list-cycle-ii.md; 287:./287-find-the-duplicate-number.md; 19:./019-remove-nth-from-end.md#linked-list #floyd #cycle-detection #fast-slow
142142. Linked List Cycle IIFast & Slow Pointers (Floyd + entry)Medium141:./141-linked-list-cycle.md; 287:./287-find-the-duplicate-number.md; 202:../../math-geometry/problems/202-happy-number.md#linked-list #floyd #cycle-entry #fast-slow
143143. Reorder ListIn-place Linked List Reversal + mergeMedium206:./206-reverse-linked-list.md; 234:./234-palindrome-linked-list.md; 21:./021-merge-two-sorted-lists.md#linked-list #split-list #reverse-half #interleave-merge
146146. LRU CacheHash map + doubly linked list (recency ordering)Medium138:./138-copy-list-with-random-pointer.md; 21:./021-merge-two-sorted-lists.md; 2:./002-add-two-numbers.md#design #hashmap #doubly-linked-list #eviction #recency
206206. Reverse Linked ListIn-place Linked List ReversalEasy92:./092-reverse-linked-list-ii.md; 234:./234-palindrome-linked-list.md; 143:./143-reorder-list.md#linked-list #in-place #three-pointer #reversal
234234. Palindrome Linked ListIn-place Linked List Reversal + Fast & SlowEasy206:./206-reverse-linked-list.md; 143:./143-reorder-list.md; 92:./092-reverse-linked-list-ii.md#linked-list #palindrome #middle-split #reverse-half
287287. Find the Duplicate NumberFast & Slow Pointers (Floyd on implicit graph)Medium142:./142-linked-list-cycle-ii.md; 141:./141-linked-list-cycle.md; 202:../../math-geometry/problems/202-happy-number.md#floyd #index-graph #pigeonhole #cycle-entry
77. Reverse IntegerMath + overflow guard (canonical home for this problem)Medium009:./009-palindrome-number.md; 008:./008-string-to-integer-atoi.md#overflow #digit-manipulation #math #int32-bounds
88. String to Integer (atoi)Parsing (state / deterministic scan)Medium007:./007-reverse-integer.md; 066:./066-plus-one.md#parsing #atoi #overflow-clamp #string-scan
99. Palindrome NumberReverse half (integer / math)Easy125:../../two-pointers/problems/125-valid-palindrome.md; 007:./007-reverse-integer.md#palindrome #reverse-half #math #no-extra-space
4343. Multiply StringsString math (grade-school multiplication)Medium066:./066-plus-one.md; 050:./050-pow-x-n.md#string-math #grade-school #carry #digit-array #multiply
5050. Pow(x, n)Fast exponentiation (Divide & Conquer)Medium372:./372-super-pow.md; 043:./043-multiply-strings.md#fast-exponentiation #binary-exponentiation #divide-conquer #math
6666. Plus OneMath simulation (grade-school carry)Easy43:./043-multiply-strings.md; 50:./050-pow-x-n.md#carry #digits #simulation #array #math
149149. Max Points on a LineCo-linearity via reduced slope (hash map) — plain text + prefix patterns not centralHard202:./202-happy-number.md; 43:./043-multiply-strings.md; 233:./233-number-of-digit-one.md#slope-hash #gcd-normalize #duplicates #pair-key #o-n-squared
202202. Happy NumberCycle detection (Fast & Slow Pointers); digit simulationEasy009:./009-palindrome-number.md; 050:./050-pow-x-n.md#cycle-detection #floyd #digit-sum #math-simulation #happy-number
233233. Number of Digit OneDigit / positional counting + Dynamic Programming — digit DP (constructive closed form here)Hard50:./050-pow-x-n.md; 43:./043-multiply-strings.md; 149:./149-max-points-on-a-line.md#digit-dp #positional-count #high-current-low #range-aggregate #math-trick
372372. Super PowModular exponentiation (Divide & Conquer)Medium050:./050-pow-x-n.md; 043:./043-multiply-strings.md#modular-exponentiation #super-pow #digit-array #recurrence #math
003003. Longest Substring Without Repeating CharactersSliding WindowMedium567:./567-permutation-in-string.md; 438:./438-find-all-anagrams-in-a-string.md; 209:./209-minimum-size-subarray-sum.md#sliding-window #variable-window #unique-chars #last-seen #expand-contract
030030. Substring with Concatenation of All WordsSliding Window (fixed multi-unit window + hash map)Hard567:./567-permutation-in-string.md; 438:./438-find-all-anagrams-in-a-string.md; 76:./076-minimum-window-substring.md#sliding-window #fixed-window #multiset #word-grid-offset #same-length-words #hard-string
076076. Minimum Window SubstringSliding Window (variable window + need/have)Hard3:./003-longest-substring-without-repeating.md; 567:./567-permutation-in-string.md; 30:./030-substring-with-concatenation-of-all-words.md#sliding-window #minimum-window #need-have #formed #two-map #hard-string
10041004. Max Consecutive Ones IIISliding WindowMedium424:./424-longest-repeating-character-replacement.md; 904:./904-fruit-into-baskets.md; 209:./209-minimum-size-subarray-sum.md#sliding-window #binary-array #zero-budget #flip #maximize-length
209209. Minimum Size Subarray SumSliding WindowMedium904:./904-fruit-into-baskets.md; 3:./003-longest-substring-without-repeating.md; 121:../../arrays-hashing/problems/121-best-time-to-buy-sell-stock.md#sliding-window #variable-window #prefix-sum-window #positive-integers #minimum-length
239239. Sliding Window MaximumMonotonic Deque / Stack (queue variant)Hard739:../../stack/problems/739-daily-temperatures.md; 424:./424-longest-repeating-character-replacement.md; 76:./076-minimum-window-substring.md#sliding-window #monotonic-deque #fixed-k #amortized-O1 #queue-indices
424424. Longest Repeating Character ReplacementSliding WindowMedium1004:./1004-max-consecutive-ones-iii.md; 904:./904-fruit-into-baskets.md; 3:./003-longest-substring-without-repeating.md#sliding-window #frequency #budget #maximize-window #uppercase-english
438438. Find All Anagrams in a StringSliding WindowMedium567:./567-permutation-in-string.md; 3:./003-longest-substring-without-repeating.md; 049:../../arrays-hashing/problems/049-group-anagrams.md#sliding-window #fixed-window #anagram #all-indices #frequency-match
567567. Permutation in StringSliding WindowMedium438:./438-find-all-anagrams-in-a-string.md; 3:./003-longest-substring-without-repeating.md; 209:./209-minimum-size-subarray-sum.md#sliding-window #fixed-window #anagram #frequency-vector #lowercase-english
904904. Fruit Into BasketsSliding WindowMedium424:./424-longest-repeating-character-replacement.md; 3:./003-longest-substring-without-repeating.md; 1004:./1004-max-consecutive-ones-iii.md#sliding-window #at-most-k-distinct #two-types #frequency-map #longest-window
992992. Subarrays with K Different IntegersSliding Window (at-most trick)Hard904:./904-fruit-into-baskets.md; 424:./424-longest-repeating-character-replacement.md; 76:./076-minimum-window-substring.md#sliding-window #exactly-k #at-most-trick #subarray-count #frequency-map #hard-classic
020020. Valid ParenthesesStack MatchEasy22:./022-generate-parentheses.md; 394:./394-decode-string.md; 71:./071-simplify-path.md#stack #parentheses #lifo #matching #brackets
022022. Generate ParenthesesDFS / BacktrackingMedium020:./020-valid-parentheses.md; 150:./150-evaluate-reverse-polish-notation.md; 394:./394-decode-string.md#backtracking #parentheses #catalan #constraints #dfs
071071. Simplify PathStack (token processing)Medium020:./020-valid-parentheses.md; 394:./394-decode-string.md; 150:./150-evaluate-reverse-polish-notation.md#stack #path #tokenize #normalize #unix-path
084084. Largest Rectangle in HistogramMonotonic Stack / QueueHard739:./739-daily-temperatures.md; 42:../../two-pointers/problems/042-trapping-rain-water.md; 239:../../sliding-window/problems/239-sliding-window-maximum.md#monotonic-stack #histogram #largest-rectangle #sentinel-pop #width-from-boundaries #cartesian-tree
150150. Evaluate Reverse Polish NotationStack evaluationMedium394:./394-decode-string.md; 020:./020-valid-parentheses.md; 022:./022-generate-parentheses.md#stack #rpn #postfix #operators #integer-division
155155. Min StackStack + auxiliary min historyMedium020:./020-valid-parentheses.md; 739:./739-daily-temperatures.md; 232:./232-implement-queue-using-stacks.md#stack #auxiliary-stack #min-tracking #amortized-o1 #design
232232. Implement Queue using StacksTwo Stacks (amortized queue)Easy155:./155-min-stack.md; 020:./020-valid-parentheses.md; 150:./150-evaluate-reverse-polish-notation.md#stack #queue #two-stack #amortized #fifo
394394. Decode StringStack (nested expansion)Medium20:./020-valid-parentheses.md; 22:./022-generate-parentheses.md; 739:./739-daily-temperatures.md#stack #nested-brackets #decode #repeat-string #multi-digit-parse
739739. Daily TemperaturesMonotonic StackMedium853:./853-car-fleet.md; 020:./020-valid-parentheses.md; 394:./394-decode-string.md#monotonic-stack #next-greater #indices #waiting-days #linear-time
853853. Car FleetTwo Pointers + monotonic speed orderingMedium739:./739-daily-temperatures.md; 167:../../two-pointers/problems/167-two-sum-ii.md; 11:../../two-pointers/problems/011-container-with-most-water.md#stack #sort-by-position #arrival-time #merge-fleets #greedy
11661166. Design File SystemTrie path composition (Trie)Medium208:../../tries/problems/208-implement-trie.md; 706:./706-design-hashmap.md#trie #paths #prefix #filesystem #design
13961396. Design Underground SystemHash maps (trip state + rolling aggregates)Medium1166:./1166-design-file-system.md; 380:./380-insert-delete-getrandom-o1.md#hash-map #streaming-stats #rolling-average #systems-design-lite
380380. Insert Delete GetRandom O(1)Hash + Array swap-removeMedium146:../../linked-list/problems/146-lru-cache.md; 355:../../heap-priority-queue/problems/355-design-twitter.md#hash-map #dynamic-array #swap-remove #random-choice #o1
381381. Insert Delete GetRandom O(1) — Duplicates AllowedHash map (value → set of indices) + dense dynamic array, swap-with-last remove (extends 380. InsertHard380:./380-insert-delete-getrandom-o1.md; 146:../../linked-list/problems/146-lru-cache.md; 460:./460-lfu-cache.md#hash-set-per-value #dynamic-array #swap-remove #multiset #amortized-o1 #random-sampling
432432. All O`one Data StructureDoubly linked list of count buckets + hash maps (adjacent to 460. LFU / 146. LRU thinking — freqHard460:./460-lfu-cache.md; 146:../../linked-list/problems/146-lru-cache.md; 347:../../arrays-hashing/problems/347-top-k-frequent-elements.md#doubly-linked-list #frequency-bucket #hash-map #min-max-tracking #o1-amortized
460460. LFU CacheTwo-level hash + doubly linked lists per frequency (cousin of 146. LRU Cache — eviction policy diffeHard146:../../linked-list/problems/146-lru-cache.md; 432:./432-all-oone-data-structure.md; 380:./380-insert-delete-getrandom-o1.md#lfu #doubly-linked-list #hash-map #frequency-buckets #min-frequency-pointer #eviction-policy
588588. Design In-Memory File SystemTrie / prefix tree over path segments + per-node metadata (isFile, content)Hard1166:./1166-design-file-system.md; 208:../../tries/problems/208-implement-trie.md; 642:./642-design-search-autocomplete-system.md#trie #path-segments #tree-of-maps #sorted-ls #in-memory-fs
622622. Design Circular QueueArray + front/rear pointersMedium641:./641-design-circular-deque.md; 232:../../stack/problems/232-implement-queue-using-stacks.md#circular-buffer #modulo-index #fixed-capacity #queue #array
641641. Design Circular DequeArray + front/rear pointersMedium622:./622-design-circular-queue.md; 707:./707-design-linked-list.md#deque #ring-buffer #two-ended #array #modulo
642642. Design Search Autocomplete SystemTrie for prefix reachability + Top-K / Heap or offline sort per queryHard1268:../../tries/problems/1268-search-suggestions-system.md; 208:../../tries/problems/208-implement-trie.md; 355:../../heap-priority-queue/problems/355-design-twitter.md#trie #prefix-search #top-k #custom-comparator #streaming-input #autocomplete
706706. Design HashMapBucket array with chainingEasy380:./380-insert-delete-getrandom-o1.md; 1396:./1396-design-underground-system.md#hash-table #separate-chaining #mod-prime #collision-handling
707707. Design Linked ListLinked list ops with sentinelMedium206:../../linked-list/problems/206-reverse-linked-list.md; 707 vs 622:./622-design-circular-queue.md#linked-list #sentinel-node #index-walk #design
9898. Validate Binary Search TreeTree DFS with boundsMedium230:./230-kth-smallest-in-bst.md; 235:./235-lowest-common-ancestor-of-bst.md; 173:./173-binary-search-tree-iterator.md#trees #bst #dfs #bounds #interval-validation
100100. Same TreeTree DFSEasy572:./572-subtree-of-another-tree.md; 226:./226-invert-binary-tree.md; 235:./235-lowest-common-ancestor-of-bst.md#trees #dfs #structural-equality #recursion #pair-traversal
102102. Binary Tree Level Order TraversalBFSMedium199:./199-binary-tree-right-side-view.md; 116:./116-populating-next-right-pointers.md; 104:./104-maximum-depth-of-binary-tree.md#trees #bfs #level-order #queue #by-level
104104. Maximum Depth of Binary TreeTree DFSEasy226:./226-invert-binary-tree.md; 110:./110-balanced-binary-tree.md; 543:./543-diameter-of-binary-tree.md#trees #dfs #height #recursion #divide-and-conquer-on-tree
105105. Construct Binary Tree from Preorder and Inorder TraversalTree DFS (divide by root)Medium100:./100-same-tree.md; 098:./098-validate-bst.md; 226:./226-invert-binary-tree.md#trees #dfs #preorder #inorder #divide-conquer #hash-index
110110. Balanced Binary TreeTree DFS (post-order)Easy104:./104-maximum-depth-of-binary-tree.md; 543:./543-diameter-of-binary-tree.md; 236:./236-lowest-common-ancestor-of-binary-tree.md#trees #post-order #height #sentinel #bubble-up-failure
113113. Path Sum IITree DFS + backtracking and DFS / backtrackingMedium437:./437-path-sum-iii.md; 257:./257-binary-tree-paths.md; 104:./104-maximum-depth-of-binary-tree.md#trees #backtracking #root-to-leaf #path-buffer #copy-on-record
116116. Populating Next Right Pointers in Each NodeBFS (or O(1) extra using next links)Medium102:./102-binary-tree-level-order-traversal.md; 199:./199-binary-tree-right-side-view.md; 236:./236-lowest-common-ancestor-of-binary-tree.md#trees #bfs #next-pointer #perfect-tree #o1-space-trick
124124. Binary Tree Maximum Path SumTree DFS / DP on TreesHard543:./543-diameter-of-binary-tree.md; 113:./113-path-sum-ii.md; 297:./297-serialize-deserialize-binary-tree.md#tree-dp #max-path #post-order #negative-weights #arch-vs-chain #global-best
14481448. Count Good Nodes in Binary TreeTree DFS (path max so far)Medium104:./104-maximum-depth-of-binary-tree.md; 437:./437-path-sum-iii.md; 113:./113-path-sum-ii.md#trees #dfs #path-parameter #running-max #good-node
173173. Binary Search Tree IteratorIterative inorder (stack)Medium230:./230-kth-smallest-in-bst.md; 098:./098-validate-bst.md; 235:./235-lowest-common-ancestor-of-bst.md#trees #bst #iterator #stack #lazy-inorder
199199. Binary Tree Right Side ViewBFSMedium102:./102-binary-tree-level-order-traversal.md; 116:./116-populating-next-right-pointers.md; 1448:./1448-count-good-nodes-in-binary-tree.md#trees #bfs #rightmost #level-order #visibility
222222. Count Complete Tree NodesBinary search on tree using heights along left/right spinesEasy104:./104-maximum-depth-of-binary-tree.md; 110:./110-balanced-binary-tree.md; 098:./098-validate-bst.md#trees #complete-binary-tree #binary-search #height-trick #perfect-subtree
226226. Invert Binary TreeTree DFSEasy100:./100-same-tree.md; 572:./572-subtree-of-another-tree.md; 104:./104-maximum-depth-of-binary-tree.md#trees #dfs #invert #mirror #swap-children
230230. Kth Smallest Element in a BSTInorder traversal on BSTMedium098:./098-validate-bst.md; 173:./173-binary-search-tree-iterator.md; 235:./235-lowest-common-ancestor-of-bst.md#trees #bst #inorder #stack #kth-order-statistic
235235. Lowest Common Ancestor of a Binary Search TreeBST property (search-space shrink from ordered keys)Medium236:./236-lowest-common-ancestor-of-binary-tree.md; 230:./230-kth-smallest-in-bst.md; 098:./098-validate-bst.md#trees #bst #lca #range-split #iterative-walk
236236. Lowest Common Ancestor of a Binary TreeTree DFSMedium235:./235-lowest-common-ancestor-of-bst.md; 572:./572-subtree-of-another-tree.md; 100:./100-same-tree.md#trees #lca #post-order #divide #bubble-result
257257. Binary Tree PathsTree DFS + backtracking and DFS / backtrackingEasy113:./113-path-sum-ii.md; 437:./437-path-sum-iii.md; 102:./102-binary-tree-level-order-traversal.md#trees #backtracking #root-to-leaf #string-build #dfs
297297. Serialize and Deserialize Binary TreeTree DFS / String encodingHard105:./105-build-tree-from-preorder-inorder.md; 1448:./1448-count-good-nodes-in-binary-tree.md; 124:./124-binary-tree-maximum-path-sum.md#tree #serialize #preorder #sentinel #codec #dfs #reconstruct
437437. Path Sum IIIPrefix sum on tree + Tree DFSMedium113:./113-path-sum-ii.md; 1448:./1448-count-good-nodes-in-binary-tree.md; 543:./543-diameter-of-binary-tree.md#trees #prefix-sum #hashmap #backtrack-unwind #path-count
543543. Diameter of Binary TreeTree DFS (DP on tree)Easy104:./104-maximum-depth-of-binary-tree.md; 110:./110-balanced-binary-tree.md; 437:./437-path-sum-iii.md#trees #dp-on-tree #post-order #diameter #global-best
572572. Subtree of Another TreeTree DFS + isSame patternEasy100:./100-same-tree.md; 104:./104-maximum-depth-of-binary-tree.md; 235:./235-lowest-common-ancestor-of-bst.md#trees #dfs #subtree #same-tree-helper #or-recursion
12681268. Search Suggestions SystemTrie (alternative: sort + binary search on products)Medium208:./208-implement-trie.md; 648:./648-replace-words.md; 211:./211-design-add-and-search-words.md#trie #autocomplete #lex-order #prefix-search #dfs-limit
208208. Implement Trie (Prefix Tree)TrieMedium211:./211-design-add-and-search-words.md; 648:./648-replace-words.md; 1268:./1268-search-suggestions-system.md#trie #prefix-tree #insert #search #startsWith
211211. Design Add and Search Words Data StructureTrie + DFS on wildcards and DFS / backtrackingMedium208:./208-implement-trie.md; 1268:./1268-search-suggestions-system.md; 648:./648-replace-words.md#trie #wildcard #dfs #backtracking #dictionary-design
212212. Word Search IITrie + DFS / BacktrackingHard79:../../backtracking/problems/079-word-search.md; 208:./208-implement-trie.md; 30:../../sliding-window/problems/030-substring-with-concatenation-of-all-words.md#trie #backtracking #word-search #prune #grid-dfs #hard-classic #prefix-tree
648648. Replace WordsTrieMedium208:./208-implement-trie.md; 211:./211-design-add-and-search-words.md; 1268:./1268-search-suggestions-system.md#trie #prefix #replace #sentence #shortest-match
011011. Container With Most WaterTwo PointersMedium15:./015-3sum.md; 125:./125-valid-palindrome.md; 167:./167-two-sum-ii.md#two-pointers #greedy-area #inward-pointers #max-min-product
015015. 3SumTwo PointersMedium16:./016-3sum-closest.md; 18:./018-4sum.md; 167:./167-two-sum-ii.md#two-pointers #sort #dedupe #triplet #two-sum-extension
016016. 3Sum ClosestTwo PointersMedium15:./015-3sum.md; 18:./018-4sum.md; 167:./167-two-sum-ii.md#two-pointers #sort #closest-sum #absolute-diff #triplet
018018. 4SumTwo PointersMedium15:./015-3sum.md; 16:./016-3sum-closest.md; 167:./167-two-sum-ii.md#two-pointers #sort #dedupe #ksum #nested-loops
042042. Trapping Rain WaterTwo Pointers (also Dynamic Programming as equivalent formulation)Hard11:./011-container-with-most-water.md; 15:./015-3sum.md; 84:../../stack/problems/084-largest-rectangle-in-histogram.md#two-pointers #rain-water #invariant #histogram #O1-space #two-pass-alternative
075075. Sort ColorsDutch National Flag (three-way partition)Medium283:./283-move-zeroes.md; 11:./011-container-with-most-water.md; 125:./125-valid-palindrome.md#dutch-national-flag #three-way-partition #in-place #linear-time
125125. Valid PalindromeTwo PointersEasy680:./680-valid-palindrome-ii.md; 167:./167-two-sum-ii.md; 11:./011-container-with-most-water.md#two-pointers #palindrome #alphanumeric #inward-convergence #string
167167. Two Sum II — Input Array Is SortedTwo PointersMedium1:../../arrays-hashing/problems/001-two-sum.md; 15:./015-3sum.md; 11:./011-container-with-most-water.md#two-pointers #sorted-array #pair-sum #one-indexed
283283. Move ZeroesTwo PointersEasy75:./075-sort-colors.md; 27:../../arrays-hashing/problems/027-remove-element.md; 125:./125-valid-palindrome.md#two-pointers #in-place #partition #stable-order #swap-write
392392. Is SubsequenceTwo PointersEasy125:./125-valid-palindrome.md; 680:./680-valid-palindrome-ii.md; 283:./283-move-zeroes.md#two-pointers #subsequence #greedy-match #string-scan
680680. Valid Palindrome IITwo Pointers + single skipEasy125:./125-valid-palindrome.md; 392:./392-is-subsequence.md; 167:./167-two-sum-ii.md#two-pointers #palindrome #one-deletion #two-checks

Last updated on

Spotted something unclear or wrong on this page?

On this page