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
- Graph Theory188
- Array1842
- String778
- Hash Table749
- Dynamic Programming534
- Sorting483
- Greedy401
- Depth-First Search338
- Binary Search305
- Matrix267
- Breadth-First Search261
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.
Algorithms & Data Structures · Use every ticket once: Hierholzer's walk, smallest destination first.
Algorithms & Data Structures · Open roads cost 0, closed cost 1 — textbook 0-1 BFS.
Algorithms & Data Structures · Union-Find: an edge whose endpoints already share a root closes a cycle.
Algorithms & Data Structures · Cycle detection dressed up as a scheduling question.
Algorithms & Data Structures · "Bidirectional and transitive" means connected components — union-find, keyed by the smallest word.
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 · Two-colour with BFS from every unvisited node; an odd cycle is the only way to fail.
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 · Rebuild the itinerary with Hierholzer's walk, then look for a repeat.
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 · Start at n components; every successful union merges two into one.
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.
Algorithms & Data Structures · Courses run in waves, and a wave takes as long as its slowest course.
Algorithms & Data Structures · Topological order with a 26-bit mask per node: inherited = AND of the parents, final = (inherited OR allow) AND NOT disallow.
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 course may start once any one prerequisite is done: swap the max for a min and relax in topological order.
Is the Graph Three-Colourable?
Algorithms & Data Structures · Backtracking over the vertices: try each colour not used by a coloured neighbour, undo on failure.
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.
Algorithms & Data Structures · Kahn's queue over course objects; a failed attempt goes to the back of the queue and its dependants stay locked until it passes.
Algorithms & Data Structures · A failure is explained if something it depends on, transitively, failed first; the unexplained failures are the root causes.
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.
Algorithms & Data Structures · A queue with an index pointer, a visited set marked on enqueue, neighbours in the order given.
Algorithms & Data Structures · A priority queue of tentative distances; a node's distance is final the first time it is popped.
Algorithms & Data Structures · Allows flow down from every ancestor and a disallow stays local: OR the parents' allow sets in topological order, then subtract the node's own disallow.
Algorithms & Data Structures · Both allows and denies flow down the DAG as letter sets; a node's letters are its inherited allows minus its inherited denies.
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.
Algorithms & Data Structures · Two bits flow down the DAG, allowed and denied; a node has access when it inherited an allow and no deny.
Algorithms & Data Structures · One person, every cake: scan the grid once keeping the cake with the smallest Manhattan distance.
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 · 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.
Transition Graph From Access Logs
Algorithms & Data Structures · Sort each user's accesses into a path from START to END, count transitions per source, and turn the counts into probabilities.
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.
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.
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.
Cheapest Grid Path With a Fuel Tank
Algorithms & Data Structures · Each cell has an entry cost, each step burns a unit of fuel, and marked cells refill the tank: Dijkstra over (row, column, fuel left), then the follow-up for a very large tank.
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.
Asked on LeetCode
682 questions tagged Graph Theory or Math · all time
- 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
- Basic Calculator IImediumMathStringStack19 companies
- Add Two NumbersmediumLinked ListMathRecursion18 companies
- Basic CalculatorhardMathStringStackRecursion17 companies
- Rotate ImagemediumArrayMathMatrix17 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
- Roman to IntegereasyHash TableMathString14 companies
- Clone GraphmediumHash TableDepth-First SearchBreadth-First SearchGraph Theory14 companies
- Sqrt(x)easyMathBinary SearchNewton's Method14 companies
- Integer to English WordshardMathStringRecursion13 companies
- Reconstruct ItineraryhardArrayStringDepth-First SearchGraph Theory+513 companies
- Pow(x, n)mediumMathRecursion13 companies
- Unique PathsmediumMathDynamic ProgrammingCombinatorics13 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
- Longest Increasing Path in a MatrixhardArrayDynamic ProgrammingDepth-First SearchBreadth-First Search+512 companies
- Cheapest Flights Within K StopsmediumDynamic ProgrammingDepth-First SearchBreadth-First SearchGraph Theory+212 companies
- Multiply StringsmediumMathStringSimulation11 companies
- Number of ProvincesmediumDepth-First SearchBreadth-First SearchUnion-FindGraph Theory11 companies
- Insert Delete GetRandom O(1) - Duplicates allowedhardArrayHash TableMathDesign+110 companies
- Fizz BuzzeasyMathStringSimulation10 companies
- Count PrimesmediumArrayMathEnumerationNumber Theory+310 companies
- Missing NumbereasyArrayHash TableMathBinary Search+210 companies
- Parallel Courses IIIhardArrayDynamic ProgrammingGraph TheoryTopological Sort+19 companies
- Best Meeting PointhardArrayMathSortingMatrix9 companies
- Find the CelebritymediumTwo PointersGraph TheoryInteractive9 companies
- Power of TwoeasyMathBit ManipulationRecursion9 companies
- Reverse IntegermediumMath9 companies
- Maximum Product of Three NumberseasyArrayMathSorting9 companies
- Basic Calculator IIIhardMathStringStackRecursion9 companies
- Add StringseasyMathStringSimulation9 companies
- Robot Bounded In CirclemediumMathStringSimulation9 companies
- Possible BipartitionmediumDepth-First SearchBreadth-First SearchUnion-FindGraph Theory+29 companies
- Is Graph Bipartite?mediumDepth-First SearchBreadth-First SearchUnion-FindGraph Theory+29 companies
- Minimize Malware SpreadhardArrayHash TableDepth-First SearchBreadth-First Search+28 companies
- Rotate ArraymediumArrayMathTwo Pointers8 companies
- Guess the WordhardArrayMathStringMinimax+28 companies
- Design Excel Sum FormulahardArrayHash TableStringGraph Theory+38 companies
- Add DigitseasyMathSimulationNumber Theory8 companies
- Palindrome NumbereasyMath8 companies
- Network Delay TimemediumDepth-First SearchBreadth-First SearchGraph TheoryHeap (Priority Queue)+28 companies
- Fibonacci NumbereasyMathDynamic ProgrammingRecursionMemoization8 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.