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

Round Numeric Strings I

Algorithms & Data Structures · Arbitrary-precision rounding — floats need not apply.

mediumSign 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

Collect Pins from Reachable Boards

Algorithms & Data Structures · BFS over the bipartite pin-board graph without building board-to-board edges.

hardSign in to star problems

Chunked Stream Reader I

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

hardSign in to star problems

Escape-Room Leaderboard

Algorithms & Data Structures · Advance players in O(1), rank them without sorting — a linked list per room.

mediumSign in to star problems

Experiment Buckets I

Algorithms & Data Structures · Meet new group sizes while disrupting as few buckets as possible.

mediumSign 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

ID Allocator I

Algorithms & Data Structures · Smallest-free allocation under a capacity that moves at runtime.

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

Sparse Matrix Storage, Addition, and Multiplication

Algorithms & Data Structures · Storage proportional to nonzeros — and the cancellation trap.

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

Decide Target via Subsequence Plus/Multiply Expression

Algorithms & Data Structures · Expression search with precedence — the (total, pending product) trick.

hardSign in to star problems

Compute Reachable Cells for a Cleaning Robot

Algorithms & Data Structures · Slide-until-blocked physics: rest positions are the states, not cells.

mediumSign 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

Reconstruct Itinerary I

Algorithms & Data Structures · Use every ticket once: Hierholzer's walk, smallest destination first.

hardSign in to star problems

Access-Log Query System

Algorithms & Data Structures · Two sorted indexes and a binary search you write by hand.

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

Count Objects in a Pixel Grid via an API

Algorithms & Data Structures · Flood fill through an opaque API — isSameObject is the catch.

mediumSign in to star problems

Roads with Switches

Algorithms & Data Structures · Open roads cost 0, closed cost 1 — textbook 0-1 BFS.

mediumSign in to star problems

Bank Tellers I

Algorithms & Data Structures · A min-heap of (free time, agent) — tuple order breaks the ties.

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

Reverse Count-and-Say I

Algorithms & Data Structures · Parse (count, digit) pairs backward — adjacent runs must differ.

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

Shortest Path Around Obstacles

Algorithms & Data Structures · Unit steps on a grid: BFS, and the first arrival is the answer.

mediumSign in to star problems

Sensor Network I

Algorithms & Data Structures · Union-Find: an edge whose endpoints already share a root closes a cycle.

easySign 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

Brace Expansion I

Algorithms & Data Structures · Tokenize into groups of choices, then fold a cartesian product across them.

mediumSign in to star problems

Nested-Transaction KV Store

Algorithms & Data Structures · An undo log per open transaction: rollback replays it, commit hands it to the parent.

mediumSign in to star problems

Replace Without Built-ins

Algorithms & Data Structures · Two-pointer scans with no library calls — the point is proving you can.

easySign in to star problems

Drone Zone Sensor

Algorithms & Data Structures · Injected transport, upserts keyed by id, a dirty set — a small class with senior signals.

easySign in to star problems

In-Memory File System

Algorithms & Data Structures · A tree of nodes keyed by path segment — the OOD-style prompt where the implementation is the test.

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

Course Schedule

Algorithms & Data Structures · Cycle detection dressed up as a scheduling question.

mediumSign in to star problems

Boxed Sentences I

Algorithms & Data Structures · Greedy word wrap inside ASCII borders — never split a word, never start a line with punctuation.

easySign in to star problems

URL Query-String Parser

Algorithms & Data Structures · Split first, decode second — the ordering that makes the encoded-ampersand case work.

easySign in to star problems

Review Token Tagging

Algorithms & Data Structures · Case-insensitive, longest match wins, original text preserved — a trie walk from every offset.

mediumSign in to star problems

Retry Wrapper

Algorithms & Data Structures · Pluggable backoff, a retryable filter, hooks, and an abort signal around one loop.

mediumSign 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

Access-Log Request Metrics

Algorithms & Data Structures · Parse, validate, count — and pick the right denominator for the failure rate.

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

Number of Islands

Algorithms & Data Structures · Flood fill from every unvisited land cell — and know when DFS, BFS or union-find fits.

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

Design HashMap

Algorithms & Data Structures · Separate chaining with a resize at a load-factor threshold — fixed buckets aren't enough.

mediumSign in to star problems

Design Task Manager

Algorithms & Data Structures · A heap cannot update a key — push the new entry and discard stale ones at pop time.

mediumSign in to star problems

Unit Conversion I

Algorithms & Data Structures · One DFS from the base unit multiplies factors down the tree, modulo a prime.

mediumSign in to star problems

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).

mediumSign in to star problems

Sliding-Window Rate Limiter

Algorithms & Data Structures · A queue of admitted timestamps per key: evict what aged out, admit while under the limit.

mediumSign in to star problems

Lazy Nested-List Iterator

Algorithms & Data Structures · Flatten behind hasNext/next with O(depth) memory — and survive [[], [[]], [[], [3]]].

mediumSign in to star problems

Reservoir Sampling

Algorithms & Data Structures · One pass and O(k) memory: item i replaces a random slot with probability k/(i+1).

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

Precision, Recall and F1

Algorithms & Data Structures · Three guarded divisions — and 0 wherever a denominator is 0.

easySign 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

Voting System API

Algorithms & Data Structures · Idempotent writes, a separate read model, and an audit log — all three in one small service.

mediumSign in to star problems

Basic Calculator II

Algorithms & Data Structures · One pass with a stack of signed terms; the trap is integer division truncating toward zero.

mediumSign in to star problems

Sorted List to Balanced BST

Algorithms & Data Structures · Build in-order and pull values off a forward-only iterator — no middle-finding, no array copy.

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

Capture Stones on a Go Board

Algorithms & Data Structures · A group dies exactly when it has no adjacent empty point — flood fill each neighbouring enemy group.

mediumSign 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

Implement a Robust REST Create Method

Algorithms & Data Structures · Authenticate, validate, sanitise — then make POST safe to retry with an Idempotency-Key scoped to the caller.

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

Design an LRU Cache

Algorithms & Data Structures · Hash map plus doubly linked list, all operations O(1).

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

Is Graph Bipartite?

Algorithms & Data Structures · Two-colour with BFS from every unvisited node; an odd cycle is the only way to fail.

mediumSign 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

Word Ladder

Algorithms & Data Structures · BFS, not DFS — shortest path — then mention bidirectional BFS, which roughly square-roots the frontier.

hardSign in to star problems

First Duplicate Character I

Algorithms & Data Structures · The first character whose second occurrence comes earliest — one pass with a set, emoji included.

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

Domain Operation Simulator

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.

mediumSign in to star problems

Min Stack

Algorithms & Data Structures · A second stack holds the minimum at each depth, so getMin is just its top.

easySign in to star problems

Parse an Integer Without parseInt

Algorithms & Data Structures · Sign, then digits through a lookup table, accumulating n * 10 + d — and NaN for anything else.

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

Reconstruct Itinerary II

Algorithms & Data Structures · Rebuild the itinerary with Hierholzer's walk, then look for a repeat.

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

Round Numeric Strings II

Algorithms & Data Structures · Split, round each value with string arithmetic, join — floats need not apply.

mediumSign 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

Distance Between Two Points

Algorithms & Data Structures · One formula for every dimension: the square root of the summed squared differences.

easySign in to star problems

Shortest Path on a Huge Map with A*

Algorithms & Data Structures · BFS's answer, found by expanding cells in order of cost-so-far plus an admissible estimate.

mediumSign in to star problems

Shortest Path with Terrain Costs

Algorithms & Data Structures · Unequal step costs turn BFS's queue into Dijkstra's priority queue.

mediumSign in to star problems

Brace Expansion II

Algorithms & Data Structures · A three-line grammar turns nested braces into a tiny recursive-descent parser.

hardSign in to star problems

Run-Length Encode and Decode

Algorithms & Data Structures · Find the end of each run (or each number), emit, jump.

easySign 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

Sensor Network II

Algorithms & Data Structures · Start at n components; every successful union merges two into one.

easySign in to star problems

Sensor Network III

Algorithms & Data Structures · Kahn's algorithm: peel sensors with no pending inputs; leftovers mean a cycle.

mediumSign 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

Unit Conversion II

Algorithms & Data Structures · Convert through the base unit — and divide with a modular inverse, since you can't divide mod p.

hardSign in to star problems

Token-Bucket Rate Limiter

Algorithms & Data Structures · Store (tokens, last seen) per key and refill lazily on each call — O(1) per key.

mediumSign in to star problems

Compound Iterator

Algorithms & Data Structures · Chain iterables behind hasNext/next with a lookahead that skips the empty ones.

easySign in to star problems

Weighted Sampling Without Replacement

Algorithms & Data Structures · A-Res: key each item by random()^(1/weight) and keep the k largest keys.

hardSign in to star problems

Stratified Sampling with Largest-Remainder Allocation

Algorithms & Data Structures · Floor each proportional share, give leftovers to the largest remainders, sample within each stratum.

hardSign 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

Cohen's Kappa

Algorithms & Data Structures · Observed agreement corrected for the agreement two annotators would reach by chance.

mediumSign in to star problems

Unbiased pass@k

Algorithms & Data Structures · 1 − C(n − c, k) / C(n, k), computed as a running product so nothing overflows.

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

First Duplicate Character II

Algorithms & Data Structures · Where the earliest second occurrence sits — the same set scan, returning an index.

easySign 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

Multiply Without *

Algorithms & Data Structures · Binary long multiplication: add the doubled multiple for every set bit — and double with +=, not a 32-bit shift.

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

Count Each Character in First-Seen Order

Algorithms & Data Structures · One counting pass into a Map, emitted in insertion order: AAABBAA becomes 5A2B.

easySign in to star problems

Sum 1 to n Recursively

Algorithms & Data Structures · A base case at n <= 0 and one recursive call — then say where the call stack runs out.

easySign in to star problems

Square Root Without Math.sqrt

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.

easySign in to star problems

An Exact Fibonacci Generator

Algorithms & Data Structures · An infinite generator over two BigInts — ordinary numbers lose precision past the 78th term.

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

Boxed Sentences II

Algorithms & Data Structures · Each sentence wraps at its own width; one box pads every line to the widest.

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

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.

mediumSign 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

Course Completion Time I

Algorithms & Data Structures · Courses run in waves, and a wave takes as long as its slowest course.

mediumSign in to star problems

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.

hardSign in to star problems

Letter Permissions Down a DAG

Algorithms & Data Structures · Topological order with a 26-bit mask per node: inherited = AND of the parents, final = (inherited OR allow) AND NOT disallow.

mediumSign in to star problems

Wiki Page Links I

Algorithms & Data Structures · BFS over an implicit graph, fetching each page exactly once.

mediumSign in to star problems

Wiki Page Links II

Algorithms & Data Structures · Store one predecessor per page, not a path per queue entry, and walk it back from the target.

mediumSign in to star problems

Wiki Page Links III

Algorithms & Data Structures · A BFS that keeps going after the target is gone — and the thread-safety story that comes with 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

Tiered Token-Bucket Limiter

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.

mediumSign in to star problems

Count Events in a Time Range

Algorithms & Data Structures · Timestamps arrive in order, so each type's list is already sorted and a count is two binary searches.

easySign in to star problems

SnowCal Interpreter

Algorithms & Data Structures · One register, a dictionary of recorded bodies, and a mode flag that says whether a line runs or is being stored.

mediumSign in to star problems

Priority Task Executor

Algorithms & Data Structures · A heap of entries with lazy deletion: a task added twice has two entries, and the stale one is skipped on the way out.

mediumSign in to star problems

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.

mediumSign in to star problems

Reverse Each Alphanumeric Run

Algorithms & Data Structures · Two pointers per run: find where the run ends, reverse it in place, carry on from there.

easySign 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

JSON Parser

Algorithms & Data Structures · Recursive descent with one cursor: a value function that dispatches on the next character, and a parser per kind.

hardSign in to star problems

Document Store With Boolean Queries

Algorithms & Data Structures · An inverted index plus a tiny expression parser whose values are sets of document ids.

hardSign in to star problems

Does This Connect Four Move Win?

Algorithms & Data Structures · Only the four lines through the last move can have changed, so count outward in each direction from it.

easySign 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

Tree Height After Deletions I

Algorithms & Data Structures · A deleted node hands its children to its nearest surviving ancestor, so it simply adds no level.

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

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.

mediumSign in to star problems

Is the Graph Three-Colourable?

Algorithms & Data Structures · Backtracking over the vertices: try each colour not used by a coloured neighbour, undo on failure.

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

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.

hardSign 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

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.

mediumSign in to star problems

Drop and Remove Runs in a Grid

Algorithms & Data Structures · Mark every horizontal and vertical run of three or more, clear them all at once, let columns fall, and repeat until nothing is marked.

mediumSign in to star problems

Course Schedule With Retries

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.

mediumSign in to star problems

Service-Failure Forensics

Algorithms & Data Structures · A failure is explained if something it depends on, transitively, failed first; the unexplained failures are the root causes.

mediumSign in to star problems

String-Command Calculator

Algorithms & Data Structures · A recursive-descent parser: a command's operand is either an integer or a parenthesised sub-program evaluated from zero.

mediumSign in to star problems

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.

hardSign in to star problems

Serialize a Dictionary Trie

Algorithms & Data Structures · Pre-order with explicit end-of-word marks and parentheses around children; parsing it back is a recursive descent.

mediumSign in to star problems

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.

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

Breadth-First Search Order

Algorithms & Data Structures · A queue with an index pointer, a visited set marked on enqueue, neighbours in the order given.

easySign 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

Dijkstra's Shortest Distances

Algorithms & Data Structures · A priority queue of tentative distances; a node's distance is final the first time it is popped.

mediumSign in to star problems

Asked on LeetCode

3,115 questions · 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.