Merge k sorted listsCodingYou get k singly linked lists, each sorted in ascending order. Merge them into one sorted linked list and return its head, reusing the existing nodes.
Last asked Nov 2026
+5
Top K frequent elementsCodingGiven an integer array and k, return the k values that occur most often. Order them by count, highest first; break ties by the smaller value.
Last asked Nov 2026
Key-value cache with per-entry TTLCodingImplement an in-memory key-value cache where every write gives a key, a value and a time-to-live. Once an entry's time is up it must behave as if it was never written.
Meeting rooms with delayed starts: the busiest roomCodingThere are n rooms numbered 0 to n - 1, and a list of meetings [start, end) with distinct start times. Meetings are assigned in order of their original start time.
Top k values per key in a MapReduce jobCodingWrite the reduce side of a MapReduce job that finds the k largest values for every key. The mapper passes each (key, value) pair through unchanged, and the shuffle groups the…
Last asked Oct 2026
Median of several sorted arraysCodingYou get several integer arrays, each sorted in non-decreasing order. Return the median of all their values taken together.
Last asked Oct 2026
Debug a Python job schedulerCodingYou own a small in-process job scheduler. It runs on a fake clock so it can be tested.
Last asked Oct 2026
Top-k prefix suggestions filtered by departmentCodingA service keeps a static list of suggestions, each a tuple (ngram, department, score). Given what the user has typed so far and their department, return the k best suggestions…
Last asked Sep 2026
Top k with a deterministically noisy comparatorCodingYou have n numbers and must return the k largest, but you may compare them only through cmp(a, b), and it is wrong about 10% of the time. The mistakes are sticky: if cmp(x, y) is…
Last asked Sep 2026
Alien dictionary with the smallest valid orderCodingYou get a list of password hints that is sorted under an unknown alphabet. Work out an order of the characters consistent with that sorting.
Last asked Sep 2026
Rotating title picker for a home-page billboardCodingBuild the in-memory component that decides which title to show next, for example in a home-page billboard or a playlist. Every title has a numeric score that can change at any…
Last asked Sep 2026
Lexicographically smallest topological orderCodingYou have n tasks and a list of dependencies between them. Return an order that runs every task after all the tasks it depends on.
Last asked Sep 2026
Merge sorted arrays, then sort files too large for memoryCodingStart by merging two sorted arrays of integers. The interviewer then scales the same task twice: first the two inputs are huge sorted files that do not fit in memory, and neither…
Minimum buses to run a timetableCodingA bus schedule lists every trip. Find the minimum number of buses that can serve all of them.
Last asked Sep 2026
+1
Find the median from a data streamCodingNumbers arrive one at a time. After any of them, you must be able to report the median of all numbers seen so far.
Last asked Sep 2026
Min-priority queue without a library heapCodingImplement a min-priority queue of integers yourself, without a library heap or a sorted container. It must support adding a value, reading the smallest, removing the smallest…
Last asked Aug 2026
Kth largest element in a streamCodingValues arrive one at a time. After each new value, report the kth largest value seen so far, counting duplicates separately.
Last asked Aug 2026
+2
Meeting rooms II: fewest rooms for a set of meetingsCodingGiven meetings as half-open intervals [start, end), find the fewest rooms needed so that no two overlapping meetings share a room, and assign every meeting a room. A meeting that…
Last asked Aug 2026
K closest points to a query locationCodingGiven a list of 2D points and a query location, return the k points closest to the query by Euclidean distance.
Fewest rental cars for a set of reservationsCodingEach rental reservation has a pickup time and a return time. Find the fewest cars that can serve every reservation, and assign each reservation to a numbered car.
Last asked Aug 2026
Reusable locker allocation systemCodingBuild a locker bank that hands out lockers and takes them back so they can be reused. Storing a package assigns the lowest-numbered free locker; picking it up frees that locker…
Schedule tasks with cooldownsCodingA CPU runs one task per time unit. Tasks have types, and two tasks of the same type must be at least n time units apart (between them there are at least n other slots, busy or…
Last asked Jul 2026
Most frequent IP addresses in a file too big for memoryCodingA log file holds one IPv4 address per line and is far larger than memory (say 500 GB of lines on a machine with 1 GB of RAM). Find the most frequent address, then the k most…
Last asked Jun 2026
Priority task executor with duplicate task idsCodingDesign and implement an in-memory priority task executor. Tasks are submitted with an id and a priority, and the executor runs them highest priority first.
Last asked Jun 2026
Busiest meeting room after simulated bookingsCodingSimulate booking meetings into n rooms numbered 0 to n - 1, and return the room that held the most meetings. Agree on the rules first; unless the interviewer sets others, use…
Last asked Mar 2026
Top K largest distinct valuesCodingGiven an integer array that may contain repeated values, return the k largest distinct values, largest first. Unless you agree on a different interface with the interviewer…
Last asked Mar 2026
Ads retrieval service using a heapCodingBuild a small ads retrieval service that keeps a pool of ads, each with a score (for example predicted value), and returns the best k ads for a request, ranked by score. Ads are…
Last asked Mar 2026
Kth largest element in an arrayCodingGiven an unsorted integer array nums and an integer k, return the k-th largest element. Duplicates count as separate elements, so in 5, 5, 4 the 2nd largest is 5. Discuss the time…
Minimum servers for daily jobs that wrap past midnightCodingEach job runs every day during a fixed window on a 24-hour clock, given as start, end) in hours. A window can wrap past midnight: when start end, the job runs from start to…
Trapping rain water IICodingYou get a 2D grid of cell heights. After heavy rain, water collects in the low parts of the grid; it can run off the outer edge, so a cell holds water only when it is walled in…
Last asked Feb 2026
K-th largest value over the last N seconds of a streamCodingTwo parts. First, return the k-th largest element of an array. Then values arrive one at a time with timestamps, and queries ask for the k-th largest among the values seen in the…
Last asked Jan 2026
Top-k and bottom-k words in a list and in a streamCodingFind the most and least frequent words, first in a fixed list, then in a stream that never ends, then for words seen only once. - topbottomk(words: liststr, k: int) -…
Last asked Jan 2026
K largest subset sumsCodingYou get n items with non-negative integer weights and an integer k. Every subset of the items has a sum (the empty subset sums to 0). Return the k largest subset sums in…
Last asked Jan 2026
Logger that reports its top K messagesCodingBuild an in-memory logger. It receives messages with timestamps and, at any point, returns the k most frequent messages: over everything logged so far, and then over a given time…
Last asked Jan 2026
+2
Find K pairs with the smallest sumsCodingYou get two integer arrays, nums1 and nums2, each sorted in non-decreasing order, and an integer k. A pair takes one number from each array. Return the k pairs with the smallest…
Last asked Dec 2025
Top K similar movies from a similarity graphCodingMovies form an undirected similarity graph: adji lists the movies directly similar to movie i, and each movie has a rating. A user liked start. Recommend up to k movies they have…
Last asked Dec 2025
Running median of a streamCodingIntegers arrive one at a time. After each one, report the median of everything seen so far. To keep the output exact, report twice the median: for an odd count, two times the…
Last asked Dec 2025
The skyline problem: outline of overlapping buildingsCodingBuildings stand on flat ground, each given as left, right, height with left < right. They may overlap. Return the skyline they form seen from far away: the list of key points x…
Report timed-out simulations from start, ping and end eventsCodingYou monitor many simulations running at once. Each sends events: start when it begins, ping while it is alive, and end when it finishes. Events arrive one at a time in time order…
Last asked Dec 2025
Many timers on top of one underlying timerCodingThe system gives you one hardware-style timer: settimer(timestamp) schedules it for an absolute time, and calling it again replaces the previous setting. When it expires, the…
Last asked Dec 2025
Best score from three books in different categoriesCodingA student's reading log is a list of (category, points) pairs, one per book read. Score the log: count at most three books, at most one book from any category, and return the…
Last asked Dec 2025
Top K most active users from chat logsCodingA chat log is a list of messages, each recorded as the id of the user who sent it. A user's activity is the number of messages they sent. Return the k most active users. Show at…
Last asked Dec 2025
Employee free time: common free intervals across schedulesCodingYou get every person's busy times for one day. Each person's list is sorted and has no overlaps. Return the intervals within the day when nobody is busy. Unless you agree on a…
Last asked Nov 2025
Merge k sorted arraysCodingYou get k arrays of integers, each sorted in non-decreasing order, with N elements in total. Merge them into one sorted array. Scanning every array's head at each step costs…
Last asked Oct 2025
+1
Sliding window median of every k-length windowCodingGiven an integer array nums and a window size k, return the median of every contiguous window of length k, as the window slides one position at a time from left to right. For an…
Last asked Oct 2025
K closest points to the originCodingGiven points in the plane and an integer k, return the k points closest to the origin. Unless you agree on a different interface with the interviewer, assume: - kclosest(points:…
Last asked Oct 2025
Kth smallest element in a sorted matrixCodingEvery row and every column of an n x n matrix is sorted in non-decreasing order. Return the k-th smallest value in the matrix, counting duplicates. Unless you agree on a different…
Last asked Sep 2025
Top three scores for each studentCodingYou get a list of (studentid, score) records. Return, for each student, their three highest scores in descending order. First solve it with no assumptions about the scores. Then…
Last asked Aug 2025
Log manager that evicts the least important logsCodingDesign an in-memory log manager that holds at most totalmax logs. Each log has an id, an importance and a timestamp. When adding a log would go over the limit, the manager first…
Last asked Aug 2025
Max stack: a stack that can pop its largest valueCodingDesign a stack that, besides the usual operations, can return the largest value and remove it. When the largest value appears more than once, popmax removes the copy closest to…
Last asked Jul 2025
Check whether a binary tree is a max-heapCodingDecide whether a binary tree is a valid max-heap. Two things must hold: the tree is complete (every level is full except possibly the last, which is filled from the left with no…
Last asked Jul 2025
Maximize capital with K projects (IPO)CodingYou start with capital w and may complete at most k projects, each at most once. Project i needs at least capitali to start (the capital is not spent) and adds profitsi to your…