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.
- String778
- Dynamic Programming534
- Sorting483
- Greedy401
- Recursion60
- Array1842
- Hash Table749
- Math565
- Depth-First Search338
- Binary Search305
- Matrix267
- Breadth-First Search261
Algorithms & Data Structures · Greedy line packing and fiddly space math — full text justification.
Algorithms & Data Structures · Arbitrary-precision rounding — floats need not apply.
Algorithms & Data Structures · Order and duplicates vanish at every depth — canonicalize.
Assign Pins to Shortest Columns
Algorithms & Data Structures · The masonry-layout greedy: shortest column wins, leftmost on ties.
Algorithms & Data Structures · Reassemble lines from arbitrary chunks, reading lazily.
Algorithms & Data Structures · Meet new group sizes while disrupting as few buckets as possible.
Algorithms & Data Structures · Interval sweep for the free ranges — independent of bucket-space size.
Cross-Reference Logs to Flag Spam Numbers
Algorithms & Data Structures · A hash join across two logs — and saying that word out loud.
Decide Target via Subsequence Plus/Multiply Expression
Algorithms & Data Structures · Expression search with precedence — the (total, pending product) trick.
Maximize Boxes Stored Through One Entrance
Algorithms & Data Structures · Prefix-min ceilings plus an exchange-argument greedy.
Algorithms & Data Structures · Net the balances, then match debtors to creditors greedily.
Restaurant Seating: Free Intervals
Algorithms & Data Structures · A +ppl/−ppl sweep; occupancy is constant between events.
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.
Stateful Search Autocomplete Session
Algorithms & Data Structures · A typing session over search counts: top three by frequency, then alphabetically.
Algorithms & Data Structures · Parse (count, digit) pairs backward — adjacent runs must differ.
Algorithms & Data Structures · Sort both teams, pair i-th against i-th, and try both orders.
Algorithms & Data Structures · The largest nearest-sensor gap — sort one side, binary search from the other.
Algorithms & Data Structures · Interval greedy: extend coverage with the farthest-reaching clip that still connects.
Algorithms & Data Structures · Unbounded knapsack in disguise — say that out loud, then roll a 1-D table.
Algorithms & Data Structures · Tokenize into groups of choices, then fold a cartesian product across them.
Algorithms & Data Structures · Two-pointer scans with no library calls — the point is proving you can.
Algorithms & Data Structures · A tree of nodes keyed by path segment — the OOD-style prompt where the implementation is the test.
Algorithms & Data Structures · Greedy word wrap inside ASCII borders — never split a word, never start a line with punctuation.
Algorithms & Data Structures · Split first, decode second — the ordering that makes the encoded-ampersand case work.
Algorithms & Data Structures · Case-insensitive, longest match wins, original text preserved — a trie walk from every offset.
Algorithms & Data Structures · Consume the oldest stock first and say which lots an order drew from — an implementation prompt with tie-break rules.
Algorithms & Data Structures · Parse, validate, count — and pick the right denominator for the failure rate.
Memory-Bounded Ranked Ballot Counter
Algorithms & Data Structures · Millions of ballots, Borda scoring, and memory that stays O(candidates) — the constraint is the question.
Algorithms & Data Structures · Bucket sort when the multiset fits, a size-N heap when it's a stream — say both.
Algorithms & Data Structures · "Bidirectional and transitive" means connected components — union-find, keyed by the smallest word.
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 · Two heaps — a max-heap for the lower half, a min-heap for the upper — rebalanced on every add.
Algorithms & Data Structures · Map, combine, partition, sort, reduce — the three parts a groupby does not have are the whole grade.
Algorithms & Data Structures · One pass with a stack of signed terms; the trap is integer division truncating toward zero.
Algorithms & Data Structures · Build the trie first and say why: it prunes the DFS the moment a prefix does not exist.
Algorithms & Data Structures · Sort, then sweep — the pattern behind a dozen calendar problems.
Algorithms & Data Structures · A 26-count key instead of sorting each word — the only decision in the problem.
Algorithms & Data Structures · BFS, not DFS — shortest path — then mention bidirectional BFS, which roughly square-roots the frontier.
Algorithms & Data Structures · The first character whose second occurrence comes earliest — one pass with a set, emoji included.
Algorithms & Data Structures · PUT, GET and a COUNT of everything under a domain: match on the label boundary, then make COUNT fast with a trie.
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 · Split the nonzero balances into as many zero-sum groups as possible.
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 · Split, round each value with string arithmetic, join — floats need not apply.
Algorithms & Data Structures · Reassemble the lines, net the balances, then search for the fewest transfers.
Algorithms & Data Structures · Only faced pairs matter: greedily match the smaller team into the larger.
Algorithms & Data Structures · The greedy match, written into two rows with empty slots.
Fewest Towers to Cover Every Crossing
Algorithms & Data Structures · Greedy: place each tower as far right as the leftmost uncovered crossing allows.
Algorithms & Data Structures · A three-line grammar turns nested braces into a tiny recursive-descent parser.
Algorithms & Data Structures · Find the end of each run (or each number), emit, jump.
Algorithms & Data Structures · A read pointer and a write pointer over the same array — write never passes read.
Algorithms & Data Structures · The farthest-reach greedy again, remembering which clip won each round.
Algorithms & Data Structures · Sweep sorted clips tracking the farthest end; a start past it opens a gap.
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 · Sort by (entity, time), then extend or open one session per entity in a single sweep.
Algorithms & Data Structures · Discount each graded relevance by log2(position + 2), then divide by the ideal ordering's DCG.
Algorithms & Data Structures · Buffer bytes across recv calls, split on newlines, and decode only whole lines.
Algorithms & Data Structures · Where the earliest second occurrence sits — the same set scan, returning an index.
Count Each Character in First-Seen Order
Algorithms & Data Structures · One counting pass into a Map, emitted in insertion order: AAABBAA becomes 5A2B.
Algorithms & Data Structures · A base case at n <= 0 and one recursive call — then say where the call stack runs out.
Algorithms & Data Structures · Levels from the top down, one character per column — ground, water, or air.
Algorithms & Data Structures · Each sentence wraps at its own width; one box pads every line to the widest.
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 · One register, a dictionary of recorded bodies, and a mode flag that says whether a line runs or is being stored.
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 · Two pointers per run: find where the run ends, reverse it in place, carry on from there.
Algorithms & Data Structures · Turn each match into a clipped line range, merge ranges that touch, and print a separator between the groups left.
Algorithms & Data Structures · Recursive descent with one cursor: a value function that dispatches on the next character, and a parser per kind.
Document Store With Boolean Queries
Algorithms & Data Structures · An inverted index plus a tiny expression parser whose values are sets of document ids.
Top K Search Terms, One Vote per User
Algorithms & Data Structures · Dedupe (user, term) pairs before counting, then sort by count with the term as the tie-break.
Top K Selling Books After Each Sale
Algorithms & Data Structures · Totals in a map; the top K is recomputed from the map on each update, or kept in a bounded structure when K is small and the catalogue huge.
Algorithms & Data Structures · Dutch national flag with three pointers, using only getColor and swap — one pass, no counting.
Algorithms & Data Structures · A course may start once any one prerequisite is done: swap the max for a min and relax in topological order.
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.
Algorithms & Data Structures · Meeting rooms with stations: a bus is reusable only where it arrived, so keep the idle buses per station.
Filter With a Dynamic Blacklist
Algorithms & Data Structures · Emitted items are final; held items wait in publish order and are re-checked whenever a word is unblocked.
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.
Document Coverage: The Shortest Window
Algorithms & Data Structures · Minimum window over tokens: expand until every term is covered, shrink while it stays covered, keep the shortest.
Algorithms & Data Structures · A recursive-descent parser: a command's operand is either an integer or a parenthesised sub-program evaluated from zero.
Algorithms & Data Structures · Pre-order with explicit end-of-word marks and parentheses around children; parsing it back is a recursive descent.
Algorithms & Data Structures · Split in half, sort each half, merge with two indices — stable, O(n log n), and the merge is the whole interview.
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 · The commands become a prefix grammar: an expression is an integer or (OP expr expr), evaluated by recursive descent over the tokens.
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 · Optional location, minimum-age and maximum-age constraints combined with AND or OR; an absent constraint is ignored, and no constraint matches everything.
Algorithms & Data Structures · Runways are workers and flights are tasks: a heap of free times hands each flight, in start order, to the runway that frees up first.
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.
Algorithms & Data Structures · Map each name to how many times it appears; the second warm-up of the data-science screen.
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.
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.
Algorithms & Data Structures · Count consonants as you scan, advance every nth one to the next consonant with wrap-around, and keep its case.
Top N Matches From a Constant-Time Score
Algorithms & Data Structures · P candidates, an O(1) score, N much smaller than P: a min-heap of size N beats sorting, in time and in space.
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.
Subarray With the Largest Min Plus Max
Algorithms & Data Structures · It looks like a sliding-window problem and is not one: the best subarray of length two or more is always an adjacent pair.
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.
Algorithms & Data Structures · Inside backticks, snake_case identifiers become camelCase and UPPER_CASE constants stay; everything else, including every space, is copied through.
Algorithms & Data Structures · Count pairs of numbers that are digit rotations of each other: give every number a canonical rotation and count equal keys instead of comparing pairs.
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.
Reverse Words, Keeping the Spacing
Algorithms & Data Structures · Reverse the order of the words while every run of spaces stays exactly where it was, including leading and trailing runs.
All Valid Expansions of Wildcard Parentheses
Algorithms & Data Structures · The follow-up to the wildcard validity check: enumerate every distinct balanced string the stars can produce, pruning on the running balance.
Algorithms & Data Structures · For every concentric ring, collect the values clockwise from the ring's top-left corner, sort them, and write them back in the same order; single-row and single-column centres are the trap.
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 · Turn a map of arbitrary strings into one string and back. Any separator can appear in the data, so the format has to say where each field ends: length prefixes.
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
1,616 questions tagged Recursion or Dynamic Programming or Greedy or String or Sorting · all time
- Merge IntervalsmediumArraySortingQuicksort45 companies
- Trapping Rain WaterhardArrayTwo PointersDynamic ProgrammingStack+128 companies
- Valid ParentheseseasyStringStackBracket Sequences28 companies
- Group AnagramsmediumArrayHash TableStringSorting27 companies
- Longest Substring Without Repeating CharactersmediumHash TableStringSliding Window27 companies
- Find Median from Data StreamhardTwo PointersDesignSortingHeap (Priority Queue)+126 companies
- Text JustificationhardArrayStringSimulation26 companies
- Time Based Key-Value StoremediumHash TableStringBinary SearchDesign26 companies
- Top K Frequent ElementsmediumArrayHash TableDivide and ConquerSorting+425 companies
- Best Time to Buy and Sell StockeasyArrayDynamic Programming24 companies
- Meeting Rooms IImediumArrayTwo PointersGreedySorting+224 companies
- Word LadderhardHash TableStringBreadth-First SearchBidirectional Search22 companies
- Minimum Window SubstringhardHash TableStringSliding Window21 companies
- Longest Palindromic SubstringmediumTwo PointersStringDynamic ProgrammingManacher21 companies
- String CompressionmediumTwo PointersString20 companies
- House RobbermediumArrayDynamic Programming20 companies
- Basic Calculator IImediumMathStringStack19 companies
- Word SearchmediumArrayStringBacktrackingDepth-First Search+119 companies
- Kth Largest Element in an ArraymediumArrayDivide and ConquerSortingHeap (Priority Queue)+119 companies
- Add Two NumbersmediumLinked ListMathRecursion18 companies
- Maximal SquaremediumArrayDynamic ProgrammingMatrix18 companies
- Maximum SubarraymediumArrayDivide and ConquerDynamic Programming18 companies
- 3SummediumArrayTwo PointersSorting18 companies
- Basic CalculatorhardMathStringStackRecursion17 companies
- Decode StringmediumStringStackRecursion17 companies
- Implement Trie (Prefix Tree)mediumHash TableStringDesignTrie17 companies
- Coin ChangemediumArrayDynamic ProgrammingBreadth-First SearchKnapsack Problem+117 companies
- Reverse Linked ListeasyLinked ListRecursion17 companies
- Binary Tree Maximum Path SumhardDynamic ProgrammingTreeDepth-First SearchBinary Tree+117 companies
- Merge Two Sorted ListseasyLinked ListRecursion17 companies
- String to Integer (atoi)mediumString16 companies
- Alien DictionaryhardArrayStringDepth-First SearchBreadth-First Search+316 companies
- Letter Combinations of a Phone NumbermediumHash TableStringBacktracking16 companies
- Climbing StairseasyMathDynamic ProgrammingMemoization16 companies
- Task SchedulermediumArrayHash TableGreedySorting+216 companies
- Container With Most WatermediumArrayTwo PointersGreedy16 companies
- Evaluate DivisionmediumArrayStringDepth-First SearchBreadth-First Search+515 companies
- Maximum Profit in Job SchedulinghardArrayBinary SearchDynamic ProgrammingSorting15 companies
- Top K Frequent WordsmediumArrayHash TableStringTrie+415 companies
- Integer to RomanmediumHash TableMathString15 companies
- Merge Sorted ArrayeasyArrayTwo PointersSorting15 companies
- Longest Common PrefixeasyArrayStringTrie15 companies
- Generate ParenthesesmediumStringDynamic ProgrammingBacktrackingBracket Sequences15 companies
- Accounts MergemediumArrayHash TableStringDepth-First Search+315 companies
- Best Time to Buy and Sell Stock IImediumArrayDynamic ProgrammingGreedy14 companies
- Find the Length of the Longest Common PrefixmediumArrayHash TableStringTrie14 companies
- Roman to IntegereasyHash TableMathString14 companies
- Word BreakmediumArrayHash TableStringDynamic Programming+314 companies
- Regular Expression MatchinghardStringDynamic ProgrammingRecursion14 companies
- Word Break IIhardArrayHash TableStringDynamic Programming+314 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.