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.
- Math565
- Breadth-First Search261
- Tree242
- Array1842
- String778
- Hash Table749
- Dynamic Programming534
- Sorting483
- Greedy401
- Depth-First Search338
- Binary Search305
- Matrix267
Algorithms & Data Structures · Arbitrary-precision rounding — floats need not apply.
Collect Pins from Reachable Boards
Algorithms & Data Structures · BFS over the bipartite pin-board graph without building board-to-board edges.
Compute Reachable Cells for a Cleaning Robot
Algorithms & Data Structures · Slide-until-blocked physics: rest positions are the states, not cells.
Mark and Compact a Heap-Indexed Subtree
Algorithms & Data Structures · Garbage collection in miniature: mark a subtree, compact, remap.
Algorithms & Data Structures · BFS over routes, not stops — clear each stop as you expand it.
Algorithms & Data Structures · Two out-edges per index: a graph search with a visited array.
Count Objects in a Pixel Grid via an API
Algorithms & Data Structures · Flood fill through an opaque API — isSameObject is the catch.
Algorithms & Data Structures · Open roads cost 0, closed cost 1 — textbook 0-1 BFS.
Shortest Path Around Obstacles
Algorithms & Data Structures · Unit steps on a grid: BFS, and the first arrival is the answer.
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.
Nth Node at Level L in a 0/1 Tree
Algorithms & Data Structures · Never build the tree — halve recursively, or read the answer off the parity of popcount(n − 1).
Algorithms & Data Structures · One pass and O(k) memory: item i replaces a random slot with probability k/(i+1).
Algorithms & Data Structures · Three guarded divisions — and 0 wherever a denominator is 0.
Algorithms & Data Structures · One pass with a stack of signed terms; the trap is integer division truncating toward zero.
Algorithms & Data Structures · Build in-order and pull values off a forward-only iterator — no middle-finding, no array copy.
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 · BFS, not DFS — shortest path — then mention bidirectional BFS, which roughly square-roots the frontier.
Parse an Integer Without parseInt
Algorithms & Data Structures · Sign, then digits through a lookup table, accumulating n * 10 + d — and NaN for anything else.
Algorithms & Data Structures · BFS from the start: the layer where the last index appears is the answer.
Algorithms & Data Structures · Split, round each value with string arithmetic, join — floats need not apply.
Algorithms & Data Structures · One formula for every dimension: the square root of the summed squared differences.
Algorithms & Data Structures · Kahn's algorithm: peel sensors with no pending inputs; leftovers mean a cycle.
Algorithms & Data Structures · Convert through the base unit — and divide with a modular inverse, since you can't divide mod p.
Algorithms & Data Structures · Store (tokens, last seen) per key and refill lazily on each call — O(1) per key.
Stratified Sampling with Largest-Remainder Allocation
Algorithms & Data Structures · Floor each proportional share, give leftovers to the largest remainders, sample within each stratum.
Algorithms & Data Structures · Discount each graded relevance by log2(position + 2), then divide by the ideal ordering's DCG.
Algorithms & Data Structures · Observed agreement corrected for the agreement two annotators would reach by chance.
Algorithms & Data Structures · 1 − C(n − c, k) / C(n, k), computed as a running product so nothing overflows.
Algorithms & Data Structures · Binary long multiplication: add the doubled multiple for every set bit — and double with +=, not a 32-bit shift.
Algorithms & Data Structures · Each position multiplies its two successors, wrapping around the end with modular indices.
Algorithms & Data Structures · A base case at n <= 0 and one recursive call — then say where the call stack runs out.
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 · An infinite generator over two BigInts — ordinary numbers lose precision past the 78th term.
Nearest Bathroom for Every Desk
Algorithms & Data Structures · Seed the queue with every bathroom and expand once — one BFS for the whole floor, not one per desk.
Algorithms & Data Structures · Courses run in waves, and a wave takes as long as its slowest course.
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 · BFS over an implicit graph, fetching each page exactly once.
Algorithms & Data Structures · Store one predecessor per page, not a path per queue entry, and walk it back from the target.
Algorithms & Data Structures · A BFS that keeps going after the target is gone — and the thread-safety story that comes with it.
Algorithms & Data Structures · Per-client (tokens, last seen), a tier config read on every call, and an explicit fallback for clients with no valid tier.
Algorithms & Data Structures · A deleted node hands its children to its nearest surviving ancestor, so it simply adds no level.
Pick the Query Type That Maximises Revenue
Algorithms & Data Structures · Committing to one type, you run it floor(k / duration) times; score every type and keep the best, earliest on ties.
Reach a Target With +2, Double and Halve
Algorithms & Data Structures · Any sequence counts, so think constructively: +2 keeps parity, doubling then +2s then halving shifts it, and halving is how you get smaller.
Count the Nodes of a Tree by Messages
Algorithms & Data Structures · A node asks every neighbour except the one that asked it, sums the replies plus one, and remembers answers so duplicates are harmless.
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.
Delete a Node From a Forest Stored as a Parent Array
Algorithms & Data Structures · Children of the deleted node are re-parented to its parent; a deleted root's children become roots.
Rewrite Two Complete Trees With Subtree Sums
Algorithms & Data Structures · In array form the children of i are 2i + 1 and 2i + 2, so merge by index and accumulate sums from the last index down.
Algorithms & Data Structures · A queue with an index pointer, a visited set marked on enqueue, neighbours in the order given.
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.
Algorithms & Data Structures · One person, every cake: scan the grid once keeping the cake with the smallest Manhattan distance.
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 · Kahn's algorithm with a min-heap in place of the queue: in-degrees, a frontier of ready nodes, and an empty result when a node never becomes ready.
Algorithms & Data Structures · Iterate the digit-square sum until a value repeats; the loop is the path from that value's first visit, and a happy number's loop is just [1].
Algorithms & Data Structures · One memo shared across every start: each value on a walk inherits the answer of where the walk stopped, so no value is followed twice.
Rank Vectors by Cosine Similarity
Algorithms & Data Structures · Score every candidate against the query, keep the indices with the scores, sort descending; the zero vector needs a defined answer.
When Do the Chasing Points Meet?
Algorithms & Data Structures · N points in a cycle each move at unit speed toward the next one; simulate with a step small enough that the meeting time is right to the hundredth.
Algorithms & Data Structures · Create, list, delete and move resources in an in-memory tree: parent pointers for the upward checks, ordered child lists for the downward ones.
Validated Add-Subtract Calculator
Algorithms & Data Structures · Evaluate digits joined by + and - only after proving the string is well formed: no stray characters, no leading zeros, no doubled operators, and everything inside 32 bits.
Largest Number Below a Limit From Allowed Digits
Algorithms & Data Structures · Keep the limit's prefix as long as possible, step one digit down, then fill with the largest allowed digit; fall back to a shorter number, and mind leading zeros.
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.
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.
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.
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
897 questions tagged Tree or Breadth-First Search or Math · all time
- Number of IslandsmediumArrayDepth-First SearchBreadth-First SearchUnion-Find+136 companies
- Rotting OrangesmediumArrayBreadth-First SearchMatrix26 companies
- Course Schedule IImediumDepth-First SearchBreadth-First SearchGraph TheoryTopological Sort25 companies
- Insert Delete GetRandom O(1)mediumArrayHash TableMathDesign+124 companies
- Course SchedulemediumDepth-First SearchBreadth-First SearchGraph TheoryTopological Sort+123 companies
- Word LadderhardHash TableStringBreadth-First SearchBidirectional Search22 companies
- Basic Calculator IImediumMathStringStack19 companies
- Add Two NumbersmediumLinked ListMathRecursion18 companies
- Basic CalculatorhardMathStringStackRecursion17 companies
- Rotate ImagemediumArrayMathMatrix17 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
- Climbing StairseasyMathDynamic ProgrammingMemoization16 companies
- Evaluate DivisionmediumArrayStringDepth-First SearchBreadth-First Search+515 companies
- Integer to RomanmediumHash TableMathString15 companies
- Accounts MergemediumArrayHash TableStringDepth-First Search+315 companies
- Lowest Common Ancestor of a Binary TreemediumTreeDepth-First SearchBinary TreeBinary Lifting+114 companies
- Roman to IntegereasyHash TableMathString14 companies
- Clone GraphmediumHash TableDepth-First SearchBreadth-First SearchGraph Theory14 companies
- Making A Large IslandhardArrayDepth-First SearchBreadth-First SearchUnion-Find+114 companies
- Sqrt(x)easyMathBinary SearchNewton's Method14 companies
- Serialize and Deserialize Binary TreehardStringTreeDepth-First SearchBreadth-First Search+214 companies
- Flatten Nested List IteratormediumStackTreeDepth-First SearchDesign+213 companies
- Integer to English WordshardMathStringRecursion13 companies
- Shortest BridgemediumArrayDepth-First SearchBreadth-First SearchMatrix13 companies
- Pow(x, n)mediumMathRecursion13 companies
- Shortest Path in Binary MatrixmediumArrayBreadth-First SearchMatrix13 companies
- Max Area of IslandmediumArrayDepth-First SearchBreadth-First SearchUnion-Find+113 companies
- Shortest Path in a Grid with Obstacles EliminationhardArrayBreadth-First SearchMatrix13 companies
- Validate Binary Search TreemediumTreeDepth-First SearchBinary Search TreeBinary Tree13 companies
- Unique PathsmediumMathDynamic ProgrammingCombinatorics13 companies
- Binary Tree Zigzag Level Order TraversalmediumTreeBreadth-First SearchBinary Tree13 companies
- Evaluate Reverse Polish NotationmediumArrayMathStack12 companies
- Happy NumbereasyHash TableMathTwo PointersFloyd's Cycle Finding Algorithm12 companies
- K Closest Points to OriginmediumArrayMathDivide and ConquerGeometry+412 companies
- Max Points on a LinehardArrayHash TableMathGeometry+212 companies
- Shortest Distance from All BuildingshardArrayBreadth-First SearchMatrix12 companies
- Longest Increasing Path in a MatrixhardArrayDynamic ProgrammingDepth-First SearchBreadth-First Search+512 companies
- All Nodes Distance K in Binary TreemediumHash TableTreeDepth-First SearchBreadth-First Search+112 companies
- Diameter of Binary TreeeasyTreeDepth-First SearchBinary TreeDP on Trees12 companies
- Cheapest Flights Within K StopsmediumDynamic ProgrammingDepth-First SearchBreadth-First SearchGraph Theory+212 companies
- Open the LockmediumArrayHash TableStringBreadth-First Search+112 companies
- Word Ladder IIhardHash TableStringBacktrackingBreadth-First Search+112 companies
- The MazemediumArrayDepth-First SearchBreadth-First SearchMatrix12 companies
- Bus RouteshardArrayHash TableBreadth-First Search11 companies
- Multiply StringsmediumMathStringSimulation11 companies
- Number of ProvincesmediumDepth-First SearchBreadth-First SearchUnion-FindGraph Theory11 companies
- Maximum Depth of Binary TreeeasyTreeDepth-First SearchBreadth-First SearchBinary Tree11 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.