Patterns TBD
These are candidate low-level problem types to promote into Patterns after solving enough examples.
Source signal used for this pass:
- Public LeetCode company-wise mirror: krishnadey30/LeetCode-Questions-CompanyWise
- Sampled
6monthsCSVs for Microsoft, Google, Amazon, Facebook/Meta, and Apple. - Caveat: live LeetCode company tags are premium and move over time. Treat this page as a curated drill map, not an exact current ranking dump.
Legend: MS Microsoft, GOOG Google, AMZN Amazon, META Facebook/Meta, AAPL Apple.
Pattern Count by Category
| Category | Count |
|---|---|
| 1-D Dynamic Programming | 2 |
| 2-D Dynamic Programming | 1 |
| Advanced Graphs | 1 |
| Arrays & Hashing | 7 |
| Backtracking | 1 |
| Binary Search | 2 |
| Bit Manipulation | 0 |
| Graphs | 6 |
| Greedy | 0 |
| Heap / Priority Queue | 3 |
| Intervals | 2 |
| Linked List | 2 |
| Math & Geometry | 1 |
| Sliding Window | 3 |
| Stack | 2 |
| Trees | 5 |
| Tries | 1 |
| Two Pointers | 1 |
| Total | 40 |
Table of Contents
1-D Dynamic Programming
- 20 - 1-D Dynamic Programming - Word Break Segmentation
- 40 - 1-D Dynamic Programming - Prefix-Index DP
2-D Dynamic Programming
Advanced Graphs
Arrays & Hashing
- 1 - Arrays & Hashing - Prefix Sum + Frequency Map
- 2 - Arrays & Hashing - Left/Right Contribution Pass
- 13 - Arrays & Hashing - Prefix Sampling
- 14 - Arrays & Hashing - Hash + Doubly Linked List Cache
- 15 - Arrays & Hashing - O(1) Mutable Indexing
- 16 - Arrays & Hashing - Time-Indexed Design
- 35 - Arrays & Hashing - In-Place Index Marking
Backtracking
Binary Search
- 36 - Binary Search - Binary Search on Answer
- 37 - Binary Search - Search in Shifted, 2D, or Unknown Space
Graphs
- 21 - Graphs - Grid Flood Fill and Island Shape
- 22 - Graphs - Multi-Source Grid BFS
- 23 - Graphs - Implicit State Shortest Path
- 24 - Graphs - Graph Components: Tree, Clone, Connected
- 25 - Graphs - Union-Find Entity Merge
- 26 - Graphs - Graph Coloring and Bipartition
Heap / Priority Queue
- 10 - Heap / Priority Queue - K-Way Merge Frontier
- 11 - Heap / Priority Queue - Top-K and Selection
- 12 - Heap / Priority Queue - Streaming Median and Order Stats
Intervals
Linked List
Math & Geometry
Sliding Window
- 3 - Sliding Window - Variable Sliding Window Counts
- 4 - Sliding Window - Fixed Window Counter Match
- 5 - Sliding Window - Monotonic Window Queue
Stack
Trees
- 28 - Trees - Tree Serialization and Structural Identity
- 29 - Trees - Tree Postorder Gain DP
- 30 - Trees - Tree Views and Coordinate Traversal
- 31 - Trees - BST Ordered Iteration and Repair
- 32 - Trees - Binary Tree Construction
Tries
Two Pointers
1 - Arrays & Hashing - Prefix Sum + Frequency Map
- Trigger: count/existence of subarrays with a target sum, equal balance, or divisible sum.
- Move: scan once; store previous prefix sums or remainders in a map.
Questions:
- 560. Subarray Sum Equals K - MS/GOOG/AMZN/META
- 523. Continuous Subarray Sum - AMZN/META
- 525. Contiguous Array - GOOG/AMZN/META/AAPL
2 - Arrays & Hashing - Left/Right Contribution Pass
- Trigger: each index answer depends on everything before and after it, but division or nested loops are awkward.
- Move: build prefix contribution, suffix contribution, or do two directional passes.
Questions:
- 238. Product of Array Except Self - MS/GOOG/AMZN/META/AAPL
- 42. Trapping Rain Water - MS/GOOG/AMZN/META/AAPL
- 724. Find Pivot Index - MS/META
3 - Sliding Window - Variable Sliding Window Counts
- Trigger: longest/shortest substring or subarray with at most/exactly some character/count constraint.
- Move: expand right, update counts, shrink left while invalid.
Questions:
- 3. Longest Substring Without Repeating Characters - MS/GOOG/AMZN/META/AAPL
- 340. Longest Substring with At Most K Distinct Characters - MS/GOOG/AMZN/META
- 424. Longest Repeating Character Replacement - GOOG
- 1004. Max Consecutive Ones III - AMZN/META
4 - Sliding Window - Fixed Window Counter Match
- Trigger: permutation/anagram/subsequence window of fixed length or minimum covering window.
- Move: maintain deficit counts and a matched/need counter instead of comparing full maps.
Questions:
- 76. Minimum Window Substring - GOOG/AMZN/META/AAPL
- 438. Find All Anagrams in a String - MS/GOOG/AMZN/META
- 567. Permutation in String - MS/AMZN/META
5 - Sliding Window - Monotonic Window Queue
- Trigger: sliding window max/min, or window validity depends on current max and min.
- Move: keep one or two monotonic deques; evict stale indices as left moves.
Questions:
- 239. Sliding Window Maximum - MS/GOOG/AMZN/AAPL
- 1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit - GOOG
- 862. Shortest Subarray with Sum at Least K - GOOG/AMZN
6 - Stack - Monotonic Stack
- Trigger: next greater/smaller element, histogram area, removing digits/letters greedily.
- Move: maintain a stack whose values stay increasing or decreasing; pop when the new item proves old items are done.
Questions:
- 84. Largest Rectangle in Histogram - GOOG/AMZN
- 907. Sum of Subarray Minimums - MS
- 739. Daily Temperatures - AMZN
- 316. Remove Duplicate Letters - GOOG/AMZN
- 503. Next Greater Element II - AMZN/META
7 - Two Pointers - Sorted Two-Pointer k-Sum
- Trigger: pair/triplet/quad constraints after sorting, usually sum-related.
- Move: sort, fix outer values, then move left/right inward; skip duplicates at the level they are created.
Questions:
- 15. 3Sum - MS/GOOG/AMZN/META/AAPL
- 16. 3Sum Closest - GOOG/AMZN/META/AAPL
- 18. 4Sum - MS/AMZN/AAPL
- 11. Container With Most Water - AMZN/META/AAPL
8 - Intervals - Interval Merge and Intersection
- Trigger: sorted ranges need to be merged, inserted, intersected, or made non-overlapping.
- Move: sort by start time, carry current merged interval, or walk two interval lists together.
Questions:
- 56. Merge Intervals - MS/GOOG/AMZN/META/AAPL
- 57. Insert Interval - GOOG/AMZN/META
- 986. Interval List Intersections - GOOG/AMZN/META/AAPL
- 435. Non-overlapping Intervals - AMZN/META
9 - Intervals - Timeline Sweep
- Trigger: rooms, calendars, overlapping events, employee free time, or active count over time.
- Move: convert intervals to start/end events or use a min-heap of end times.
Questions:
- 253. Meeting Rooms II - MS/GOOG/AMZN/META/AAPL
- 759. Employee Free Time - MS/GOOG/AMZN/META
- 1229. Meeting Scheduler - MS/GOOG/AMZN/AAPL
- 729. My Calendar I - GOOG/AMZN/AAPL
10 - Heap / Priority Queue - K-Way Merge Frontier
- Trigger: many sorted lists/rows/streams and the next global smallest/largest is needed.
- Move: seed a heap with one item per source, then push the next item from the same source after popping.
Questions:
- 23. Merge k Sorted Lists - MS/GOOG/AMZN/META/AAPL
- 632. Smallest Range Covering Elements from K Lists - AMZN/AAPL
- 373. Find K Pairs with Smallest Sums - AMZN/META
- 378. Kth Smallest Element in a Sorted Matrix - MS/GOOG/AMZN/META
11 - Heap / Priority Queue - Top-K and Selection
- Trigger: kth largest/smallest, top frequent, nearest points, or keep only the best
kcandidates. - Move: use quickselect, a size-k heap, or bucket counts depending on mutability and ordering needs.
Questions:
- 692. Top K Frequent Words - MS/GOOG/AMZN/META/AAPL
- 347. Top K Frequent Elements - GOOG/AMZN/META/AAPL
- 973. K Closest Points to Origin - AMZN/META/AAPL
- 215. Kth Largest Element in an Array - MS/GOOG/AMZN/META/AAPL
12 - Heap / Priority Queue - Streaming Median and Order Stats
- Trigger: median or percentile after each insertion, or a sliding window median.
- Move: two heaps for online median; lazy deletion when window removals are involved.
Questions:
- 295. Find Median from Data Stream - MS/GOOG/AMZN/META/AAPL
- 480. Sliding Window Median - GOOG/AMZN/META/AAPL
- 352. Data Stream as Disjoint Intervals - GOOG/AMZN
13 - Arrays & Hashing - Prefix Sampling
- Trigger: random choice with weights or repeated random pick by index.
- Move: build prefix sums and binary-search a random target; use reservoir sampling when the stream is not fully stored.
Questions:
- 528. Random Pick with Weight - MS/GOOG/AMZN/META/AAPL
- 398. Random Pick Index - META
- 384. Shuffle an Array - GOOG/META
14 - Arrays & Hashing - Hash + Doubly Linked List Cache
- Trigger:
getandputmust be O(1), but eviction depends on recency or frequency. - Move: hash key to node; move nodes between linked lists or frequency buckets.
Questions:
- 146. LRU Cache - MS/GOOG/AMZN/META/AAPL
- 460. LFU Cache - MS/AMZN
- 432. All O(1) Data Structure - MS/AMZN/META
15 - Arrays & Hashing - O(1) Mutable Indexing
- Trigger: insert/delete/get-random or frequency stack with constant-time operations.
- Move: pair array storage with a value-to-index map; for duplicates, map value to a set of indices.
Questions:
- 380. Insert Delete GetRandom O(1) - MS/GOOG/AMZN/META
- 381. Insert Delete GetRandom O(1) - Duplicates allowed - META
- 895. Maximum Frequency Stack - AMZN
16 - Arrays & Hashing - Time-Indexed Design
- Trigger: queries ask for the latest value at or before a timestamp/version.
- Move: append sorted
(time, value)records per key, then binary-search on query.
Questions:
- 981. Time Based Key-Value Store - GOOG/AMZN/AAPL
- 1146. Snapshot Array - GOOG/AMZN
- 362. Design Hit Counter - MS/GOOG/AMZN/AAPL
- 359. Logger Rate Limiter - GOOG/AMZN/AAPL
17 - Stack - Stack Simulation and Expression Parsing
- Trigger: nested expressions, calculators, decoded strings, call logs, or reverse-polish tokens.
- Move: use stacks for frames/operators; decide whether precedence is handled during scan or during unwind.
Questions:
- 636. Exclusive Time of Functions - MS/GOOG/AMZN/META/AAPL
- 394. Decode String - MS/GOOG/AMZN/AAPL
- 224. Basic Calculator - MS/GOOG/AMZN/META
- 227. Basic Calculator II - MS/GOOG/AMZN/META/AAPL
- 150. Evaluate Reverse Polish Notation - GOOG/AMZN/META
18 - Math & Geometry - Structured String Parsing and Formatting
- Trigger: custom numeric/string grammar, IPs, atoms, file paths, or human-readable conversion.
- Move: write a small deterministic parser; keep token boundaries explicit.
Questions:
- 273. Integer to English Words - MS/GOOG/AMZN/META/AAPL
- 65. Valid Number - GOOG/AMZN/META
- 726. Number of Atoms - AMZN
- 388. Longest Absolute File Path - AMZN/AAPL
19 - Tries - Trie Search and Autocomplete
- Trigger: prefix search, wildcard search, stream suffix lookup, or board word search with many words.
- Move: build a trie; store terminal metadata; prune exhausted branches during DFS.
Questions:
- 208. Implement Trie (Prefix Tree) - MS/GOOG/AMZN/META
- 211. Add and Search Word - Data structure design - GOOG/AMZN/META/AAPL
- 212. Word Search II - MS/GOOG/AMZN/META/AAPL
- 1268. Search Suggestions System - AMZN
- 642. Design Search Autocomplete System - GOOG/AMZN/AAPL
20 - 1-D Dynamic Programming - Word Break Segmentation
- Trigger: split a string into dictionary words, return possible sentences, or identify compound words.
- Move: memoize by start index; optionally use a trie to avoid trying every word.
Questions:
- 139. Word Break - MS/GOOG/AMZN/META/AAPL
- 140. Word Break II - MS/AMZN/META/AAPL
- 472. Concatenated Words - AMZN/META/AAPL
21 - Graphs - Grid Flood Fill and Island Shape
- Trigger: connected land/cells, island area/count/perimeter/closedness/distinct shape.
- Move: DFS/BFS from each unvisited cell; mark immediately; encode shape when identity matters.
Questions:
- 200. Number of Islands - MS/GOOG/AMZN/META/AAPL
- 695. Max Area of Island - MS/GOOG/AMZN/META
- 733. Flood Fill - MS/GOOG/AMZN/AAPL
- 1254. Number of Closed Islands - GOOG/AMZN/META
- 694. Number of Distinct Islands - AMZN/META
22 - Graphs - Multi-Source Grid BFS
- Trigger: nearest gate/zero/land/infection time, or shortest bridge from all frontier cells.
- Move: seed queue with all sources at distance
0; expand level by level.
Questions:
- 994. Rotting Oranges - MS/AMZN
- 542. 01 Matrix - AMZN/AAPL
- 286. Walls and Gates - GOOG/AMZN/META
- 1162. As Far from Land as Possible - AMZN
- 934. Shortest Bridge - MS/META
23 - Graphs - Implicit State Shortest Path
- Trigger: each state is not just a node; it can include word, board layout, bus route, key count, or obstacle budget.
- Move: BFS over state tuples; visited must include the full state dimensions.
Questions:
- 127. Word Ladder - MS/GOOG/AMZN/META/AAPL
- 126. Word Ladder II - MS/AMZN/META/AAPL
- 752. Open the Lock - GOOG
- 773. Sliding Puzzle - MS/GOOG/META
- 1293. Shortest Path in a Grid with Obstacles Elimination - GOOG
24 - Graphs - Graph Components: Tree, Clone, Connected
- Trigger: graph must be cloned, validated as a tree, counted by component, or searched through weighted relationships.
- Move: build adjacency; BFS/DFS/Union-Find; for tree, require
edges === n - 1plus connectivity.
Questions:
- 133. Clone Graph - MS/GOOG/AMZN/META/AAPL
- 323. Number of Connected Components in an Undirected Graph - AMZN/META
- 261. Graph Valid Tree - AMZN
- 547. Friend Circles - AMZN/META
- 399. Evaluate Division - MS/GOOG/AMZN/META
25 - Graphs - Union-Find Entity Merge
- Trigger: items are equivalent by shared email/name/row/column/string transform.
- Move: union identifiers, then group by root; choose stable representatives carefully.
Questions:
- 721. Accounts Merge - GOOG/AMZN/META
- 839. Similar String Groups - AMZN/META
- 947. Most Stones Removed with Same Row or Column - GOOG
26 - Graphs - Graph Coloring and Bipartition
- Trigger: split nodes into two compatible groups or detect odd cycles.
- Move: BFS/DFS color each component; conflict means impossible.
Questions:
- 785. Is Graph Bipartite? - AMZN/META
- 886. Possible Bipartition - GOOG/META/AAPL
27 - Advanced Graphs - Topological Order from Dependencies
- Trigger: course order, alien language order, sequence reconstruction, or prerequisite waves.
- Move: build directed graph plus indegrees; Kahn’s BFS gives order and cycle detection.
Questions:
- 269. Alien Dictionary - MS/GOOG/AMZN/META/AAPL
- 207. Course Schedule - MS/AMZN/META
- 210. Course Schedule II - MS/GOOG/AMZN/META/AAPL
- 444. Sequence Reconstruction - GOOG
- 1136. Parallel Courses - GOOG
28 - Trees - Tree Serialization and Structural Identity
- Trigger: encode/decode trees, compare subtrees, or detect duplicate structures.
- Move: choose preorder with null markers, level-order with nulls, or postorder structural signatures.
Questions:
- 297. Serialize and Deserialize Binary Tree - MS/GOOG/AMZN/META/AAPL
- 449. Serialize and Deserialize BST - MS/AMZN/META
- 428. Serialize and Deserialize N-ary Tree - MS/GOOG/META/AAPL
- 652. Find Duplicate Subtrees - GOOG
29 - Trees - Tree Postorder Gain DP
- Trigger: answer depends on child contributions but the current node decides whether to extend or close a path.
- Move: return one value upward; update global answer with the best closed shape at the node.
Questions:
- 124. Binary Tree Maximum Path Sum - MS/GOOG/AMZN/META/AAPL
- 543. Diameter of Binary Tree - MS/GOOG/AMZN/META
- 337. House Robber III - GOOG/AMZN
- 968. Binary Tree Cameras - GOOG
- 1373. Maximum Sum BST in Binary Tree - AMZN
30 - Trees - Tree Views and Coordinate Traversal
- Trigger: vertical order, right side, boundary, zigzag, distance-k, or level-based projection.
- Move: BFS with coordinates/levels, or DFS with first-seen/ordered buckets.
Questions:
- 199. Binary Tree Right Side View - MS/AMZN/META
- 102. Binary Tree Level Order Traversal - MS/AMZN/META/AAPL
- 987. Vertical Order Traversal of a Binary Tree - MS/GOOG/AMZN/META
- 314. Binary Tree Vertical Order Traversal - GOOG/AMZN/META
- 545. Boundary of Binary Tree - MS/AMZN/AAPL
- 863. All Nodes Distance K in Binary Tree - AMZN/META/AAPL
31 - Trees - BST Ordered Iteration and Repair
- Trigger: kth/successor/iterator/delete/recover operations depend on inorder order.
- Move: use inorder traversal, explicit stack iterator, or carry predecessor pointers.
Questions:
- 173. Binary Search Tree Iterator - MS/GOOG/AMZN/META
- 285. Inorder Successor in BST - MS/AMZN/META
- 510. Inorder Successor in BST II - MS
- 230. Kth Smallest Element in a BST - AMZN/META
- 99. Recover Binary Search Tree - MS/GOOG/AMZN
32 - Trees - Binary Tree Construction
- Trigger: rebuild a tree from traversals, preorder strings, or sorted input.
- Move: pick root from preorder/postorder, split by inorder index, recurse on ranges instead of slicing arrays.
Questions:
- 105. Construct Binary Tree from Preorder and Inorder Traversal - MS/GOOG/AMZN/META
- 106. Construct Binary Tree from Inorder and Postorder Traversal - MS/AMZN
- 1008. Construct Binary Search Tree from Preorder Traversal - AMZN/META
- 536. Construct Binary Tree from String - META
33 - Linked List - Linked List Rewiring
- Trigger: nodes have random pointers, child pointers, circular order, or need cross-list identity.
- Move: interleave clones, flatten in DFS order, or carefully preserve next pointers before mutation.
Questions:
- 138. Copy List with Random Pointer - MS/AMZN/META
- 430. Flatten a Multilevel Doubly Linked List - AMZN/META
- 708. Insert into a Sorted Circular Linked List - META
34 - Linked List - Linked List Reversal and Runner
- Trigger: reverse whole list, reverse a segment, k-group reverse, reorder, palindrome, nth-from-end, or cycle.
- Move: combine fast/slow, dummy node, and
prev/curr/nextreversal.
Questions:
- 206. Reverse Linked List - MS/GOOG/AMZN/META/AAPL
- 92. Reverse Linked List II - MS/AMZN/META
- 25. Reverse Nodes in k-Group - MS/AMZN/META/AAPL
- 143. Reorder List - AMZN/META/AAPL
- 234. Palindrome Linked List - MS/AMZN/META/AAPL
35 - Arrays & Hashing - In-Place Index Marking
- Trigger: array values are in
1..nand the question asks missing/duplicate/first positive. - Move: use index-as-bucket by sign flipping, swapping into correct position, or cycle detection.
Questions:
- 41. First Missing Positive - MS/GOOG/AMZN/AAPL
- 442. Find All Duplicates in an Array - MS/GOOG/AMZN/META/AAPL
- 287. Find the Duplicate Number - MS/GOOG/AMZN/META/AAPL
- 448. Find All Numbers Disappeared in an Array - AAPL
36 - Binary Search - Binary Search on Answer
- Trigger: minimize/maximize a numeric answer where a feasibility function is monotonic.
- Move: binary-search capacity/time/largest sum; write
can(x)first.
Questions:
- 1011. Capacity To Ship Packages Within D Days - GOOG/AMZN
- 410. Split Array Largest Sum - GOOG/AMZN
- 875. Koko Eating Bananas - AMZN/META
- 1231. Divide Chocolate - GOOG
37 - Binary Search - Search in Shifted, 2D, or Unknown Space
- Trigger: sorted data is rotated, matrix-shaped, mountain-shaped, or has unknown size.
- Move: define which half or direction is still sorted/valid, then discard the impossible half.
Questions:
- 33. Search in Rotated Sorted Array - MS/GOOG/AMZN/META/AAPL
- 153. Find Minimum in Rotated Sorted Array - MS/GOOG/AMZN/AAPL
- 34. Find First and Last Position of Element in Sorted Array - MS/GOOG/AMZN/META/AAPL
- 240. Search a 2D Matrix II - MS/GOOG/AMZN/META/AAPL
- 1095. Find in Mountain Array - GOOG/AAPL
38 - Backtracking - Backtracking with Duplicate Control
- Trigger: enumerate combinations/permutations/subsets/board placements, often with duplicate input.
- Move: sort first; skip duplicates at the same depth; for boards, mark/unmark on the current recursion path.
Questions:
- 39. Combination Sum - MS/AMZN/META/AAPL
- 40. Combination Sum II - AMZN/META
- 46. Permutations - MS/GOOG/AMZN/META/AAPL
- 78. Subsets - GOOG/AMZN/META/AAPL
- 37. Sudoku Solver - MS/GOOG/AMZN/AAPL
39 - 2-D Dynamic Programming - Palindrome Center and Interval DP
- Trigger: palindrome substrings, cuts, subsequences, or minimum insertions.
- Move: use expand-around-center for substrings; use interval DP when characters at both ends interact.
Questions:
- 5. Longest Palindromic Substring - MS/GOOG/AMZN/META/AAPL
- 647. Palindromic Substrings - MS/GOOG/AMZN/META/AAPL
- 131. Palindrome Partitioning - MS/AMZN
- 132. Palindrome Partitioning II - AMZN
- 1312. Minimum Insertion Steps to Make a String Palindrome - GOOG
40 - 1-D Dynamic Programming - Prefix-Index DP
- Trigger: count ways, minimum cost, or validity for a prefix of a sequence.
- Move: let
dp[i]mean answer for prefix ending ati; transition from the few legal previous positions or choices.
Questions:
- 91. Decode Ways - MS/GOOG/AMZN/META
- 322. Coin Change - MS/GOOG/AMZN/AAPL
- 518. Coin Change 2 - MS/AMZN/AAPL
- 983. Minimum Cost For Tickets - GOOG/AMZN/META
- 70. Climbing Stairs - MS/GOOG/AMZN/META/AAPL