call(back)

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.

Max Width

Algorithms & Data Structures · Greedy line packing and fiddly space math — full text justification.

hardSign in to star problems

Violation Log Analyzer

Algorithms & Data Structures · Streaming design: recent counts, top-k, and sliding-window bans.

mediumSign in to star problems

Nested Set Equality

Algorithms & Data Structures · Order and duplicates vanish at every depth — canonicalize.

mediumSign in to star problems

Assign Pins to Shortest Columns

Algorithms & Data Structures · The masonry-layout greedy: shortest column wins, leftmost on ties.

mediumSign in to star problems

Chunked Stream Reader I

Algorithms & Data Structures · Reassemble lines from arbitrary chunks, reading lazily.

hardSign in to star problems

Experiment Buckets II

Algorithms & Data Structures · Interval sweep for the free ranges — independent of bucket-space size.

mediumSign in to star problems

Cross-Reference Logs to Flag Spam Numbers

Algorithms & Data Structures · A hash join across two logs — and saying that word out loud.

mediumSign in to star problems

Select the Nearest Eligible Elevator

Algorithms & Data Structures · A requirements-gathering problem wearing a simulation costume.

easySign in to star problems

Maximize Boxes Stored Through One Entrance

Algorithms & Data Structures · Prefix-min ceilings plus an exchange-argument greedy.

mediumSign in to star problems

Mark and Compact a Heap-Indexed Subtree

Algorithms & Data Structures · Garbage collection in miniature: mark a subtree, compact, remap.

mediumSign in to star problems

Implement Single-Tab Browser History Navigation

Algorithms & Data Structures · A cursor over one visit stack: truncate forward history, clamp at both ends.

mediumSign in to star problems

ID Allocator II

Algorithms & Data Structures · Pack named ID ranges, then resize with all-or-nothing shifts.

mediumSign in to star problems

Settle Debts I

Algorithms & Data Structures · Net the balances, then match debtors to creditors greedily.

mediumSign in to star problems

Bus Routes: Minimum Transfers

Algorithms & Data Structures · BFS over routes, not stops — clear each stop as you expand it.

hardSign in to star problems

Exact Board Jumps I

Algorithms & Data Structures · Two out-edges per index: a graph search with a visited array.

easySign in to star problems

Restaurant Seating: Free Intervals

Algorithms & Data Structures · A +ppl/−ppl sweep; occupancy is constant between events.

mediumSign in to star problems

Count Pins on a Two-Column Screen

Algorithms & Data Structures · Only n scroll offsets matter — slide the window to a pin's top.

mediumSign in to star problems

Count Subarrays with Score Below K

Algorithms & Data Structures · Positives make sum × length monotone — a two-pointer window.

mediumSign in to star problems

Prefix Search I

Algorithms & Data Structures · lower_bound on the prefix itself, then one startswith check.

easySign in to star problems

Stateful Search Autocomplete Session

Algorithms & Data Structures · A typing session over search counts: top three by frequency, then alphabetically.

hardSign in to star problems

Team Photo I

Algorithms & Data Structures · Sort both teams, pair i-th against i-th, and try both orders.

easySign in to star problems

Largest Sensor Distance

Algorithms & Data Structures · The largest nearest-sensor gap — sort one side, binary search from the other.

mediumSign in to star problems

Surveillance Footage I

Algorithms & Data Structures · Interval greedy: extend coverage with the farthest-reaching clip that still connects.

mediumSign in to star problems

Rod Cutting I

Algorithms & Data Structures · Unbounded knapsack in disguise — say that out loud, then roll a 1-D table.

mediumSign in to star problems

Pour Water I

Algorithms & Data Structures · Simulate one unit at a time — left, then right, else stay — and land only on strictly lower ground.

mediumSign in to star problems

Pair Sum in a Sorted Array

Algorithms & Data Structures · The two-pointer warm-up: one pointer at each end.

easySign in to star problems

FIFO Order Allocator

Algorithms & Data Structures · Consume the oldest stock first and say which lots an order drew from — an implementation prompt with tie-break rules.

mediumSign in to star problems

Memory-Bounded Ranked Ballot Counter

Algorithms & Data Structures · Millions of ballots, Borda scoring, and memory that stays O(candidates) — the constraint is the question.

mediumSign in to star problems

Top-N Frequent Log Lines

Algorithms & Data Structures · Bucket sort when the multiset fits, a size-N heap when it's a stream — say both.

mediumSign in to star problems

Synonym Groups

Algorithms & Data Structures · "Bidirectional and transitive" means connected components — union-find, keyed by the smallest word.

mediumSign in to star problems

Insert Interval

Algorithms & Data Structures · Three linear phases instead of a re-sort: before, overlapping, after.

mediumSign in to star problems

Median of a Stream I

Algorithms & Data Structures · Two heaps — a max-heap for the lower half, a min-heap for the upper — rebalanced on every add.

hardSign in to star problems

Implement MapReduce

Algorithms & Data Structures · Map, combine, partition, sort, reduce — the three parts a groupby does not have are the whole grade.

mediumSign in to star problems

Hotel Booking System

Algorithms & Data Structures · Half-open intervals per room, only neighbours can clash — and check-then-book must be one atomic step.

mediumSign in to star problems

Word Search on a Letter Grid

Algorithms & Data Structures · Build the trie first and say why: it prunes the DFS the moment a prefix does not exist.

hardSign in to star problems

Socket Reader II

Algorithms & Data Structures · TCP is a byte stream: buffer across calls, frame by length prefix, and tell a clean EOF from a truncated message.

mediumSign in to star problems

Merge Overlapping Intervals

Algorithms & Data Structures · Sort, then sweep — the pattern behind a dozen calendar problems.

mediumSign in to star problems

Valid Sudoku

Algorithms & Data Structures · One pass, three sets — and derive the box index out loud instead of asserting it.

easySign in to star problems

Group Anagrams

Algorithms & Data Structures · A 26-count key instead of sorting each word — the only decision in the problem.

easySign in to star problems

Unique Values Across Two Arrays I

Algorithms & Data Structures · Every value once, in first-seen order — a Set keeps insertion order.

easySign in to star problems

Array Products I

Algorithms & Data Structures · Prefix products left to right, suffix products right to left — no division, so zeros need no special case.

easySign in to star problems

Settle Debts II

Algorithms & Data Structures · Split the nonzero balances into as many zero-sum groups as possible.

hardSign in to star problems

Exact Board Jumps II

Algorithms & Data Structures · BFS from the start: the layer where the last index appears is the answer.

mediumSign in to star problems

Bank Tellers II

Algorithms & Data Structures · The count served by time T is monotone — binary search T.

mediumSign in to star problems

Prefix Search II

Algorithms & Data Structures · Matches are contiguous: lower_bound the prefix, then the prefix bumped by one.

mediumSign in to star problems

Reverse Count-and-Say II

Algorithms & Data Structures · The reverse parse, memoized on (index, previous digit) — count, don't build.

hardSign in to star problems

Chunked Stream Reader II

Algorithms & Data Structures · Reassemble the lines, net the balances, then search for the fewest transfers.

hardSign in to star problems

Team Photo II

Algorithms & Data Structures · Only faced pairs matter: greedily match the smaller team into the larger.

mediumSign in to star problems

Team Photo III

Algorithms & Data Structures · The greedy match, written into two rows with empty slots.

mediumSign in to star problems

Fewest Towers to Cover Every Crossing

Algorithms & Data Structures · Greedy: place each tower as far right as the leftmost uncovered crossing allows.

mediumSign in to star problems

String Compression in Place

Algorithms & Data Structures · A read pointer and a write pointer over the same array — write never passes read.

mediumSign in to star problems

Surveillance Footage II

Algorithms & Data Structures · The farthest-reach greedy again, remembering which clip won each round.

mediumSign in to star problems

Surveillance Footage III

Algorithms & Data Structures · Sweep sorted clips tracking the farthest end; a start past it opens a gap.

easySign in to star problems

Rod Cutting II

Algorithms & Data Structures · The rod-cutting table again, charging for every cut and seeding the whole-rod sale.

mediumSign in to star problems

Rod Cutting III

Algorithms & Data Structures · Add a piece-count dimension: dp[k][L] builds on dp[k − 1][L − p].

mediumSign in to star problems

Median of a Stream II

Algorithms & Data Structures · Buckets plus underflow and overflow: O(1) adds, any quantile, error within half a bucket.

mediumSign in to star problems

Sessionize Events by Entity

Algorithms & Data Structures · Sort by (entity, time), then extend or open one session per entity in a single sweep.

mediumSign in to star problems

NDCG@k

Algorithms & Data Structures · Discount each graded relevance by log2(position + 2), then divide by the ideal ordering's DCG.

mediumSign in to star problems

Socket Reader I

Algorithms & Data Structures · Buffer bytes across recv calls, split on newlines, and decode only whole lines.

mediumSign in to star problems

Unique Values Across Two Arrays II

Algorithms & Data Structures · Count every value across both arrays in a Map, then keep the ones counted exactly once.

easySign in to star problems

Unique Values Across Two Arrays III

Algorithms & Data Structures · Objects compare by reference, so deduplicate on a property — the first object with each key wins.

easySign in to star problems

Array Products II

Algorithms & Data Structures · Each position multiplies its two successors, wrapping around the end with modular indices.

easySign in to star problems

Pour Water II

Algorithms & Data Structures · Levels from the top down, one character per column — ground, water, or air.

easySign in to star problems

Classify a Poker Hand

Algorithms & Data Structures · A rank histogram and two booleans name every category — the ace is the only edge case.

easySign in to star problems

People and Cakes I

Algorithms & Data Structures · One pass and two remembered indexes — the last person and the last cake seen.

easySign in to star problems

People and Cakes II

Algorithms & Data Structures · Nearest-cake greedy is wrong; with both lists sorted, an optimal matching never crosses, so a 2-D DP finds it.

mediumSign in to star problems

Dropped Requests Under Two Rules

Algorithms & Data Structures · One queue of accepted timestamps per rule; dropped requests never enter either.

mediumSign in to star problems

Grep With Context Lines

Algorithms & Data Structures · Turn each match into a clipped line range, merge ranges that touch, and print a separator between the groups left.

mediumSign in to star problems

Valid Tic-Tac-Toe State

Algorithms & Data Structures · Count the pieces, then check who has a line: X leads by one if X won, counts are equal if O won, and both cannot win.

mediumSign in to star problems

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.

easySign in to star problems

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.

mediumSign in to star problems

Sort Colours Through an API

Algorithms & Data Structures · Dutch national flag with three pointers, using only getColor and swap — one pass, no counting.

mediumSign in to star problems

Course Completion Time II

Algorithms & Data Structures · A course may start once any one prerequisite is done: swap the max for a min and relax in topological order.

mediumSign in to star problems

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.

hardSign in to star problems

Minimum Bus Fleet

Algorithms & Data Structures · Meeting rooms with stations: a bus is reusable only where it arrived, so keep the idle buses per station.

mediumSign in to star problems

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.

mediumSign in to star problems

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.

easySign in to star problems

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.

easySign in to star problems

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.

mediumSign in to star problems

Merge Sort

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.

mediumSign in to star problems

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.

easySign in to star problems

Contiguous Recipe Lookup I

Algorithms & Data Structures · Many patterns, one text: a trie of the recipes with failure links finds every recipe in a single pass over the ingredients.

mediumSign in to star problems

Contiguous Recipe Lookup II

Algorithms & Data Structures · The ingredients arrive once and cannot be stored: the recipe automaton advances one state per element and never looks back.

hardSign in to star problems

Recent Event Window Queries

Algorithms & Data Structures · Keep the newest m events in arrival order; a query counts over the prefix whose timestamps fit, which is small because m is.

mediumSign in to star problems

People and Cakes III

Algorithms & Data Structures · Two sweeps along the hallway — nearest cake on the left, nearest on the right — give every person a distance in one go.

easySign in to star problems

Longest Common Substring

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.

mediumSign in to star problems

Filter Ads by a Single Rule

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.

easySign in to star problems

Set Without a Hash Function

Algorithms & Data Structures · add, remove, contains and size on a fixed-length array you allocate yourself, growing and shrinking it; then how hashing values to indices would change the costs.

mediumSign in to star problems

Assign Each Flight a Runway

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.

mediumSign in to star problems

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.

easySign in to star problems

Elementwise Matrix Sum

Algorithms & Data Structures · The warm-up of the data-science screen: add two same-shaped matrices entry by entry, empty included.

easySign in to star problems

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.

mediumSign in to star problems

Interleave Front and Back

Algorithms & Data Structures · First, last, second, second-to-last: two pointers walking inward build the new array in one pass.

easySign in to star problems

Longest Stable Transaction Period

Algorithms & Data Structures · The longest run of consecutive days whose total is divisible by k: prefix sums modulo k and the first index each remainder appeared.

mediumSign in to star problems

Does This In-Place Reverse Work?

Algorithms & Data Structures · A reversal loop that visits every index swaps each pair twice; fix the range and state the complexity.

easySign in to star problems

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.

easySign in to star problems

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.

easySign in to star problems

Fish From Decaying Ponds

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.

mediumSign in to star problems

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.

mediumSign in to star problems

Earliest Block Removal That Balances the Array

Algorithms & Data Structures · Delete k consecutive elements so the even-indexed and odd-indexed sums of what remains are equal; an alternating prefix sum handles the parity flip of the shifted suffix.

mediumSign in to star problems

Cyclic Number Pairs

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.

mediumSign in to star problems

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.

easySign in to star problems

Aligned Memory Allocator

Algorithms & Data Structures · Simulate alloc and erase over a bit array where blocks must start on an 8-cell boundary; the care is in ids, bounds and erasing something twice.

mediumSign in to star problems

House Segments After Demolitions

Algorithms & Data Structures · Houses on a number line form segments of consecutive positions; each demolition changes the segment count by +1, 0 or -1 depending only on the two neighbours.

mediumSign in to star problems

Sort Each Border of a Matrix

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.

mediumSign in to star problems

Is the Tic-Tac-Toe Game Over?

Algorithms & Data Structures · Given an n by n board, decide whether a player has completed a row, column or diagonal, or the board is full; then make it constant time per move.

easySign in to star problems

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.

hardSign in to star problems

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.

mediumSign in to star problems

Asked on LeetCode

2,020 questions tagged Data Stream or Sorting or Array or Dynamic Programming · all time

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.