Design an image sharing service that stores each file onceSystem designDesign an image sharing service where users upload images from phones and computers, browse and view them at different sizes, download them and delete them. Many uploads are…
Last asked Oct 2026
+7
Design TinyURL: a URL shortener with fast redirectsSystem designDesign a URL shortener like TinyURL. It turns a long URL into a short link (for example https://s.example.com/aZ9k2Qx) and redirects visitors to the original URL.
Check and insert among a million user IDsSystem designA service keeps a set of about one million user IDs. Every request carries a user ID: the service must say whether the ID is already in the set and, if it isn't, add it.
Last asked Oct 2026
Rank every cell of a matrix of distinct valuesCodingYou get an m x n matrix of distinct integers. Replace every value with its rank: ranks start at 1; for two cells in the same row or the same column, the larger value has a…
Last asked Sep 2026
Repository Merkle tree hashing and change detectionCodingA code editor keeps a search index of a user's repository in sync with a server. Re-uploading everything after each change is too slow, so it hashes the repository as a Merkle…
Last asked Sep 2026
+4
Deduplicate files by size then content hashCodingWalk a directory tree and group files with identical content. Compare file sizes first so large files are hashed only when sizes collide, then hash the rest.
Last asked Sep 2026
Distributed mode and median across worker shardsCodingYou are given a cluster of k worker nodes, numbered 0 to k - 1. Each worker holds its own unsorted slice (shard) of a large integer dataset.
Last asked Sep 2026
Count squares formed by vertical and horizontal segmentsCodingYou are given vertical and horizontal line segments in the plane. Wherever a vertical segment crosses or touches a horizontal one, their common point is an intersection point.
First missing positive integer in an unsorted listCodingGiven an unsorted list of integers that may include negatives, zeros, duplicates and values far larger than the list's length, return the smallest positive integer that does not…
Remove the fewest distinct values to delete half the arrayCodingYou may pick a set of distinct values from an integer array; picking a value deletes every occurrence of it. Return the size of the smallest set whose deletions remove at least…
Last asked Aug 2026
Find the words in a list that are anagrams of a targetCodingGiven a target word and a list of words, return the entries that are anagrams of the target: the same letters, each used the same number of times. Keep the list's order and keep…
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
Encode and decode TinyURLCodingImplement an in-memory class that turns a long URL into a short one and back. Any short URL produced by encode must decode to exactly the URL that was encoded.
Last asked Jun 2026
Stream of points: remove any pair within a distanceCodingPoints in the plane arrive one at a time. When a new point is within distance d of a point you are already storing, remove that stored point and do not store the new one (the…
Last asked Jun 2026
Largest axis-aligned rectangle from pointsCodingYou are given a list of distinct points on a 2D integer grid. Each point is a pair x, y. Return the largest area of a rectangle whose sides are parallel to the x and y axes and…
Last asked Apr 2026
Line reflection symmetry with duplicate pointsCodingGiven points in the plane, possibly with duplicates, decide whether some vertical line reflects the set onto itself. Duplicates count: every occurrence of a point needs a matching…
Last asked Feb 2026
Max points on a lineCodingGiven points with integer coordinates on a plane, return the largest number of them that lie on one straight line. The list may contain the same point more than once; each copy…
Last asked Feb 2026
Remove duplicates in place from an unsorted arrayCodingRemove repeated values from an unsorted integer array in place. Keep the first occurrence of each value, in its original order, at the front of the array, and return how many…
Last asked Feb 2026
Friend groups by matching last k moviesCodingA streaming service stores each customer's full viewing history, oldest title first. Two customers are friends when the set of their last k watched titles is the same. Order…
Last asked Jan 2026
Top k lottery winners by spendingCodingEach lottery entry records who bought tickets and how much they spent. A person can appear in many entries. Return the k people who spent the most in total, highest first. Unless…
Last asked Jan 2026
Design a hash map without built-in librariesCodingImplement a hash map from scratch, without any built-in hash table, dictionary, map or set. Keys and values are integers. You may use plain arrays and your own node classes…
Last asked Nov 2025
Stream deduplication with near-duplicate suppressionCodingA news pipeline receives a stream of headlines and must pass each story on once. First drop exact repeats. Then also drop a headline that is nearly the same as one already passed…
Last asked Nov 2025
Products your friends bought that you haven'tCodingRecommend products to a user from what their friends bought. Each user has a list of friends and a list of purchases; each purchase has a product id, an amount and a purchase id…
Report a user's license usage from a log fileCodingWrite a command-line script that reports one user's license usage from a log file, then make repeated lookups fast with a cache. Unless you agree on a different interface with the…
Last asked Sep 2025
Sort characters by frequencyCodingGiven a string, rearrange its characters in decreasing order of how often they appear, all copies of each character together. Characters with the same count appear in ascending…
Last asked Sep 2025
Unique visitors per department from click logsCodingAn online store has two tables. products(productid, department, category, subcategory) places every product in a hierarchy: a department contains categories, which contain…
Last asked Sep 2025
Real-time top-k products from purchase eventsCodingProduct events arrive as a continuous stream, each (timestamp, productid, eventtype) with eventtype one of "view", "addtocart" or "purchase". Each type has a configurable weight…
Last asked Sep 2025
Most equal values after shifting one subarrayCodingYou are given an integer array. You may perform at most one operation: pick a contiguous subarray and add the same integer delta (negative, zero or positive) to every element in…
Last asked Aug 2025
Find the number that appears an odd number of timesCodingIn an integer array, exactly one value appears an odd number of times and every other value appears an even number of times. Return that value. Start with any correct solution…
Last asked Aug 2025
Valid Sudoku in one passCodingGiven a partly filled 9×9 Sudoku board, decide whether the filled cells break any rule: no digit may repeat within a row, a column or one of the nine 3×3 boxes. Empty cells are…
Find a substring that splits into dictionary wordsCodingGiven a string s and a dictionary of words, find a substring of s that splits, with nothing left over, into one or more dictionary words placed back to back. Words may repeat and…
Last asked Jul 2025
Top-k clicked items over a rolling windowCodingClick events arrive as a high-volume stream, each with an event id, a timestamp in milliseconds and a URL. Build a data structure that records events and answers, at any moment…
Last asked Jul 2025
Most frequent user in access logsCodingYou get a list of access-log lines. Each line holds a username, then whitespace, then an access timestamp, for example "alice 2025-07-27T12:30:00Z". Return the username that…
Last asked Jul 2025
Inventory allocation with backordersCodingProcess a stream of events for an online store's inventory. You start with some stock per SKU. Events arrive in time order and are either an order or a restock. An order takes…
Last asked Jul 2025
First unique character in a stringCodingGiven a string s, return the index of the first character that appears exactly once in it. If every character repeats, return -1. Give an O(n) solution and compare it with a…
Last asked Jul 2025
Music player that plays the most frequent unplayed songCodingBuild a music player fed by users who keep arriving with song lists. Every appearance of a song in a list adds one to that song's global count. The player always plays the most…
Count warehouse robots boxed in on all four sidesCodingA warehouse floor is modeled as an integer grid. Each delivery robot sits at a point (xi, yi), and no two robots share a point. A robot is idle when there is at least one other…
Count reverse-complement DNA strand pairsCodingYou are given a list of DNA strands. Each strand is a non-empty string over the alphabet A, C, G, T. The reverse complement of a strand is formed by reversing it and then…
Route a request along diagonal server redirectsCodingServers sit at distinct integer points on an infinite 2D grid. locationsi = x, y is the position of server i. A request starts at server 0, which counts as visited. You are given…
Merge known bigrams in a sentence, leftmost firstCodingWrite a function that splits a sentence into tokens using a dictionary of known two-word phrases (bigrams). - text is a non-empty string of lowercase words separated by spaces. -…