Problems
Callback's own problems and the LeetCode questions companies have been asking, in one place — pick a category, then filter by company, frequency, status, difficulty, topic, and language.
- Dynamic Programming534
- Depth-First Search338
- Binary Search305
- Array1842
- String778
- Hash Table749
- Math565
- Sorting483
- Greedy401
- Matrix267
- Breadth-First Search261
- Tree242
Mark and Compact a Heap-Indexed Subtree
Algorithms & Data Structures · Garbage collection in miniature: mark a subtree, compact, remap.
Algorithms & Data Structures · Use every ticket once: Hierholzer's walk, smallest destination first.
Algorithms & Data Structures · Two sorted indexes and a binary search you write by hand.
Algorithms & Data Structures · Two out-edges per index: a graph search with a visited array.
Count Pins on a Two-Column Screen
Algorithms & Data Structures · Only n scroll offsets matter — slide the window to a pin's top.
Algorithms & Data Structures · lower_bound on the prefix itself, then one startswith check.
Algorithms & Data Structures · The largest nearest-sensor gap — sort one side, binary search from the other.
Algorithms & Data Structures · Union-Find: an edge whose endpoints already share a root closes a cycle.
Algorithms & Data Structures · Unbounded knapsack in disguise — say that out loud, then roll a 1-D table.
Algorithms & Data Structures · Cycle detection dressed up as a scheduling question.
Algorithms & Data Structures · Flood fill from every unvisited land cell — and know when DFS, BFS or union-find fits.
Algorithms & Data Structures · One DFS from the base unit multiplies factors down the tree, modulo a prime.
Algorithms & Data Structures · Half-open intervals per room, only neighbours can clash — and check-then-book must be one atomic step.
Algorithms & Data Structures · A group dies exactly when it has no adjacent empty point — flood fill each neighbouring enemy group.
Algorithms & Data Structures · Two-colour with BFS from every unvisited node; an odd cycle is the only way to fail.
Algorithms & Data Structures · Rebuild the itinerary with Hierholzer's walk, then look for a repeat.
Algorithms & Data Structures · The count served by time T is monotone — binary search T.
Algorithms & Data Structures · Matches are contiguous: lower_bound the prefix, then the prefix bumped by one.
Algorithms & Data Structures · The reverse parse, memoized on (index, previous digit) — count, don't build.
Algorithms & Data Structures · Start at n components; every successful union merges two into one.
Algorithms & Data Structures · The rod-cutting table again, charging for every cut and seeding the whole-rod sale.
Algorithms & Data Structures · Add a piece-count dimension: dp[k][L] builds on dp[k − 1][L − p].
Algorithms & Data Structures · Convert through the base unit — and divide with a modular inverse, since you can't divide mod p.
Algorithms & Data Structures · Binary-search the root in [0, max(1, x)] for a fixed number of rounds — an epsilon loop never ends for large x.
Algorithms & Data Structures · Nearest-cake greedy is wrong; with both lists sorted, an optimal matching never crosses, so a 2-D DP finds it.
Tree Height After Deletions II
Algorithms & Data Structures · Delete exactly the non-root nodes whose own subtree is k or more deep — one post-order pass, no DP.
Algorithms & Data Structures · Timestamps arrive in order, so each type's list is already sorted and a count is two binary searches.
Key-Value Store With Prefix Scan
Algorithms & Data Structures · A hash map for the point operations and a sorted key list for the scan — agree the smallest version, then extend.
Algorithms & Data Structures · A course may start once any one prerequisite is done: swap the max for a min and relax in topological order.
Algorithms & Data Structures · A deleted node hands its children to its nearest surviving ancestor, so it simply adds no level.
Most Credits With at Most K Classes
Algorithms & Data Structures · Weighted interval scheduling with a count budget: sort by end, binary-search the compatible predecessor, add a dimension for the cap.
Fewest Coins When Change Is Given
Algorithms & Data Structures · Overpaying can save coins: minimise coins handed over plus coins handed back, over every payment up to one large coin above the price.
Algorithms & Data Structures · A failure is explained if something it depends on, transitively, failed first; the unexplained failures are the root causes.
Algorithms & Data Structures · Pre-order with explicit end-of-word marks and parentheses around children; parsing it back is a recursive descent.
Pre-Order Traversal Skipping Marked Nodes
Algorithms & Data Structures · A pre-order walk with a stack; a marked node is dropped before its children are pushed, so its whole subtree disappears.
Algorithms & Data Structures · Deleting a node takes its subtree: walk down from the root, never entering a deleted node, and keep the deepest level reached.
Algorithms & Data Structures · When nodes within the limit must stay, the only cuts that can be made are the first nodes past it — and each is a separate cut.
Algorithms & Data Structures · One cut per root branch that is too deep, placed at the deepest node above all of that branch's offending nodes.
Prerequisite Route to a Target Course
Algorithms & Data Structures · Collect the courses the target depends on, then order just those with a smallest-first topological sort; a cycle among them means no route.
Repeated Lookups in a Sorted Array
Algorithms & Data Structures · Many queries against one sorted array: record each value's first index once and answer every query from that, never searching twice.
Boundary of a Full Binary Tree
Algorithms & Data Structures · With no missing children the two edges are plain spines: walk them and the leaves separately, and count the corners once.
Algorithms & Data Structures · Insertion-ordered tasks with a dependency set each: refuse an edge that would close a cycle, emit the earliest ready task, and copy both structures.
Algorithms & Data Structures · A table that resets to zero on a mismatch, so the answer is the largest cell rather than the corner, and one row of it is enough.
Algorithms & Data Structures · The Encrypt and Decrypt Strings variant the phone screen asks: return the dictionary words a ciphertext can decode to, not how many, by DFS with backtracking.
Count Cells That Climb to the Global Maximum
Algorithms & Data Structures · A deterministic greedy walk uphill from every cell with a fixed tie-break; memoise where each walk ends, since strictly increasing heights cannot cycle.
Order Validator With Rule Dependencies
Algorithms & Data Structures · Validation rules form a DAG: a rule is skipped when a prerequisite did not pass, a dependency that would close a cycle is refused, and removing a rule reconnects its prerequisites to its dependents.
Algorithms & Data Structures · Each hour fished lowers a pond's next yield by one. The heap greedy is the first answer; the accepted one finds the water line all ponds are fished down to and sums arithmetic series.
More Than a Third in a Sorted Array
Algorithms & Data Structures · In a sorted array a value that fills more than a third must cover the index at n/3 or at 2n/3, so two probes and four binary searches replace the scan.
Count Alternating-Parity Subarrays
Algorithms & Data Structures · Count the subarrays in which neighbours always differ in parity: the number ending at each index is the length of the current alternating streak.
Algorithms & Data Structures · A path whose value comparisons strictly alternate up and down. Unlike the longest increasing path, it can turn back on itself, so it needs backtracking with a visited set rather than memoisation.
Count Path Sums in an N-ary Tree
Algorithms & Data Structures · Count downward paths that add up to a target when a node can have any number of children: a prefix-sum counter that is scoped to the current root-to-node path.
Equalize Root-to-Leaf Sums in an N-ary Tree
Algorithms & Data Structures · Raise node values by one at a time until every root-to-leaf path has the same sum, using the fewest increments: lift each shortfall as high in the tree as it can go.
Binary Tree Maximum Path Sum, With the Path
Algorithms & Data Structures · The maximum path sum is the warm-up; the follow-up wants the nodes on the path, which means recording which arm each node extends and stitching two arms together at the best bend.
Heaviest Set of Non-Adjacent Nodes
Algorithms & Data Structures · House Robber on an arbitrary small graph: with at most 20 nodes, a dynamic programme over subsets decides, for the lowest remaining node, take it and drop its neighbours or skip it.
Algorithms & Data Structures · Number of Islands where the top edge touches the bottom and the left edge touches the right: wrap the neighbour arithmetic, then discuss union-find and cell flips.
Asked on LeetCode
1,047 questions tagged Depth-First Search or Dynamic Programming or Binary Search · all time
- Number of IslandsmediumArrayDepth-First SearchBreadth-First SearchUnion-Find+136 companies
- Trapping Rain WaterhardArrayTwo PointersDynamic ProgrammingStack+128 companies
- Time Based Key-Value StoremediumHash TableStringBinary SearchDesign26 companies
- Course Schedule IImediumDepth-First SearchBreadth-First SearchGraph TheoryTopological Sort25 companies
- Best Time to Buy and Sell StockeasyArrayDynamic Programming24 companies
- Course SchedulemediumDepth-First SearchBreadth-First SearchGraph TheoryTopological Sort+123 companies
- Median of Two Sorted ArrayshardArrayBinary SearchDivide and Conquer21 companies
- Longest Palindromic SubstringmediumTwo PointersStringDynamic ProgrammingManacher21 companies
- Koko Eating BananasmediumArrayBinary Search21 companies
- Search in Rotated Sorted ArraymediumArrayBinary Search20 companies
- House RobbermediumArrayDynamic Programming20 companies
- Word SearchmediumArrayStringBacktrackingDepth-First Search+119 companies
- Design Hit CountermediumArrayBinary SearchDesignQueue+118 companies
- Find First and Last Position of Element in Sorted ArraymediumArrayBinary Search18 companies
- Maximal SquaremediumArrayDynamic ProgrammingMatrix18 companies
- Maximum SubarraymediumArrayDivide and ConquerDynamic Programming18 companies
- Coin ChangemediumArrayDynamic ProgrammingBreadth-First SearchKnapsack Problem+117 companies
- Binary Tree Maximum Path SumhardDynamic ProgrammingTreeDepth-First SearchBinary Tree+117 companies
- Random Pick with WeightmediumArrayMathBinary SearchPrefix Sum+116 companies
- Alien DictionaryhardArrayStringDepth-First SearchBreadth-First Search+316 companies
- Find Peak ElementmediumArrayBinary Search16 companies
- Climbing StairseasyMathDynamic ProgrammingMemoization16 companies
- Evaluate DivisionmediumArrayStringDepth-First SearchBreadth-First Search+515 companies
- Maximum Profit in Job SchedulinghardArrayBinary SearchDynamic ProgrammingSorting15 companies
- Generate ParenthesesmediumStringDynamic ProgrammingBacktrackingBracket Sequences15 companies
- Accounts MergemediumArrayHash TableStringDepth-First Search+315 companies
- Best Time to Buy and Sell Stock IImediumArrayDynamic ProgrammingGreedy14 companies
- Lowest Common Ancestor of a Binary TreemediumTreeDepth-First SearchBinary TreeBinary Lifting+114 companies
- Clone GraphmediumHash TableDepth-First SearchBreadth-First SearchGraph Theory14 companies
- Snapshot ArraymediumArrayHash TableBinary SearchDesign+114 companies
- Word BreakmediumArrayHash TableStringDynamic Programming+314 companies
- Regular Expression MatchinghardStringDynamic ProgrammingRecursion14 companies
- Word Break IIhardArrayHash TableStringDynamic Programming+314 companies
- Making A Large IslandhardArrayDepth-First SearchBreadth-First SearchUnion-Find+114 companies
- Longest Increasing SubsequencemediumArrayBinary SearchDynamic ProgrammingLongest Increasing Subsequence14 companies
- Sqrt(x)easyMathBinary SearchNewton's Method14 companies
- Serialize and Deserialize Binary TreehardStringTreeDepth-First SearchBreadth-First Search+214 companies
- Find K Closest ElementsmediumArrayTwo PointersBinary SearchSliding Window+214 companies
- Flatten Nested List IteratormediumStackTreeDepth-First SearchDesign+213 companies
- Reconstruct ItineraryhardArrayStringDepth-First SearchGraph Theory+513 companies
- Search Suggestions SystemmediumArrayStringBinary SearchTrie+213 companies
- Shortest BridgemediumArrayDepth-First SearchBreadth-First SearchMatrix13 companies
- Palindromic SubstringsmediumTwo PointersStringDynamic Programming13 companies
- Non-overlapping IntervalsmediumArrayDynamic ProgrammingGreedySorting13 companies
- Max Consecutive Ones IIImediumArrayBinary SearchSliding WindowPrefix Sum13 companies
- Max Area of IslandmediumArrayDepth-First SearchBreadth-First SearchUnion-Find+113 companies
- House Robber IImediumArrayDynamic Programming13 companies
- Validate Binary Search TreemediumTreeDepth-First SearchBinary Search TreeBinary Tree13 companies
- Jump GamemediumArrayDynamic ProgrammingGreedy13 companies
- Maximum Product SubarraymediumArrayDynamic Programming13 companies
Listings only — titles, difficulty, and tags link out to LeetCode. Imported from the leetcode-company-wise-problems snapshot dated 1 June 2025. Frequency is that dataset's own relative score within a company and time range.