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.

Assign Pins to Shortest Columns

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

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

Access-Log Query System

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

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

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

Largest Sensor Distance

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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

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

Topological Sort

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.

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

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

Task Scheduler With Removal

Algorithms & Data Structures · addTask, removeTask and a destructive popTask(num) in timestamp order: a heap with lazy deletion, and a version per task so stale heap entries are recognised.

mediumSign in to star problems

LRU Cache With Expiry

Algorithms & Data Structures · The LRU follow-up: every entry carries a time-to-live, an expired entry is a miss, and expired entries must not take up capacity when something has to be evicted.

mediumSign 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

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.

hardSign in to star problems

Asked on LeetCode

457 questions tagged Heap (Priority Queue) or Binary Search · 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.