Interview prep · reported by candidates
What big companies reportedly asked
38 system design questions with diagrams, 26 machine coding answers with runnable code, 66 coding questions with a dry run, and 93 CS and SQL questions with model answers, for 22 companies. Cover the answer, run the clock, then compare.
- 38
- design
- 66
- coding
- 26
- machine coding
- 80
- diagrams
- 35
- widely reported
- Pick one
Filter by company, topic or how well it is reported.
- Cover and run the clock
Sketch it on paper first. The answer stays blurred until you reveal it.
- Compare and mark it
Read the diagrams or the dry run, then mark it practised.
Pick a company, see its whole process
Each page lays out the rounds in order, what gets asked in each, and the questions to practise.
GlobalBig tech and product companies
IndiaIndian product companies and startups
Every kind of round, and what it can ask
Open one to see what is usually asked, and where to prepare for it on this site.
Online assessment
A timed test on a coding platform, taken alone. Usually two or three coding problems, sometimes with multiple-choice questions on CS basics, aptitude or SQL.
What gets asked
Array and string problems that need a hash map, two pointers or a sliding window
Read the constraints first, because they point to the technique. If n is 100,000, an O(n^2) scan will time out, so look for a hash map, two pointers on a sorted array, or a window that moves forward only. Sketch the brute force, find the repeated work, then remove it. For two-sum style pairs you might say: I store each value's index as I scan, so the complement lookup is O(1) and the whole pass is O(n).
DSA courseGreedy and sorting problems with a catch in the constraints
Greedy problems hide behind a sort. Ask what ordering makes the locally best choice safe, then try to argue why swapping two adjacent choices never helps. Interval scheduling is the classic case: sort by end time and take every interval that starts after the last chosen one. Check the catch in the constraints, such as overflow, ties or equal values, and test a tiny case by hand before submitting.
DSA courseA medium dynamic programming or graph-on-a-grid problem
Decide whether the problem is a graph walk or a recurrence. On a grid, a shortest path with equal step cost is breadth-first search from the start, with a visited set so each cell is processed once, giving O(rows x cols). For dynamic programming, define the state in one sentence, write the transition, set the base cases, then see if only the previous row is needed to save space.
DSA courseSQL queries with joins and group by
Start from the table that holds the thing being counted, join the others on their keys, filter rows with WHERE, group, then filter groups with HAVING. Remember that WHERE runs before grouping and HAVING after. Use LEFT JOIN when rows with no match must still appear, and COUNT of a column rather than star when nulls matter. Example: customers with more than three orders is GROUP BY customer_id HAVING COUNT(*) > 3.
DatabasesMultiple-choice questions on OOP, operating systems, databases and networks
These reward quick, accurate recall rather than long reasoning, so revise the short list of definitions that recur. Know the difference between a process and a thread, the four ACID properties, what an index trades for faster reads, TCP against UDP, and the four pillars of OOP. Eliminate two wrong options first, then choose. Do not spend more than a minute on any single question, and flag it to return to if time remains.
Mock interviews
Or browse every answer
Open one, cover the answer, and talk it through out loud before you compare.
135 of 135 questions
- CodingMediumGoogleSeveral reportsMerge IntervalsYou are given a list of closed intervals [start, end] in no particular order. Combine every group of intervals that overlap or touch, and return the combined intervals sorted by start. For example, [[8,10],[1,3],[2,6],[15,18]] becomes [[1,6],[8,10],[15,18]]. There can be up to 10,000 intervals, and the numbers are integers.Intervals, sortingO(n log n) timeOpen
- CodingHardGoogleSeveral reportsWord Break IIGiven a string s and a list of dictionary words, put spaces into s to build every sentence in which each word comes from the dictionary. A word can be used any number of times. For example, s = "catsanddog" with the words cat, cats, and, sand, dog gives "cat sand dog" and "cats and dog". The string has up to 20 characters, and the dictionary has up to 1,000 words of length up to 10.DP with memoised backtrackingO(n·L²) plus building and sorting the sentences; exponential in n at worst timeOpen
- CodingMediumGoogleSeveral reportsMaximum Matching of Players With TrainersEach player has an ability and each trainer has a capacity. A trainer can train a player only when the capacity is at least the ability, and everyone can be in at most one pair, so return the largest number of pairs you can form. For example, players [4,7,9] and trainers [8,2,5,8] give 2. Each array holds up to 100,000 integers.Greedy, sort and two pointersO(n log n + m log m) timeOpen
- FundamentalsMany companiesSeveral reportsOperating systems: 19 reported questionsOperating systems questions reported in interviews at product and fintech companies, grouped by theme. Try each aloud first, then open the model answer and its usual follow-up.Operating systemsOpen
- FundamentalsMany companiesSeveral reportsDatabase management systems: 18 reported questionsDatabase theory questions candidates report from campus and lateral rounds, from normalisation and keys to transactions and indexing. Read the answer, then say it aloud with your own example.Database management systemsOpen
- FundamentalsMany companiesSeveral reportsSQL: 18 reported questionsEighteen SQL questions reported in interviews, each with a query and its exact output on one small sample dataset. Load the schema once, run each query yourself, then read the pitfalls.SQLOpen
- FundamentalsMany companiesSeveral reportsObject-oriented programming: 18 reported questionsObject-oriented programming questions reported by candidates in campus and experienced hiring loops, from the four pillars to SOLID, virtual dispatch, memory and design rounds. Read each answer, then say it aloud with your own example.Object-oriented programmingOpen
- CodingMediumMetaSeveral reportsBinary Tree Vertical Order TraversalA binary tree of up to 10,000 nodes is given in level-order form, with null for a missing child. Give every node a column: the root is column 0, a left child sits one column left of its parent and a right child one column right. Return the values grouped by column from left to right, listing each column top to bottom and, within one row, left to right. For example, [3,9,20,null,null,15,7] gives [[9],[3,15],[20],[7]].Tree BFS with a hash mapO(n) average, Map operations O(1) timeOpen
- CodingMediumMetaSeveral reportsSubarray Sum Equals KGiven an integer array nums and an integer k, count the contiguous, non-empty subarrays whose elements add up to exactly k. The array can contain negative numbers and zeros. For example, nums = [2,1,-1,1,2] and k = 3 gives 4. The array has up to 100,000 elements.Prefix sums with a hash mapO(n) average, Map operations O(1) timeOpen
- CodingMediumMetaSeveral reportsLowest Common Ancestor of a Binary TreeA binary tree is given in level-order form (null for a missing child) and all its values are different, and two values p and q are both in it. Return the value of the lowest node that has both p and q in its subtree, where a node counts as part of its own subtree. For example, with the tree [3,5,1,6,2,0,8,null,null,7,4], p = 6 and q = 4 give 5. The tree has up to 10,000 nodes.Tree recursionO(n) timeOpen
- System designAmazonSeveral reportsDesign a food ordering and delivery platformDesign an online food ordering and delivery platform where customers search nearby restaurants, place an order with online payment, and track a courier on a map. Assume a dinner-time peak, restaurants that must confirm each order, and couriers who report their location every few seconds.Orders and moneySDE-2 / L5Open
- CodingMediumAmazonSeveral reportsLRU CacheDesign a cache with a fixed capacity (at least 1) that supports get(key) and put(key, value), each in O(1) average time. get returns the stored value, or -1 when the key is absent, and either call counts as using that key; put updates an existing key or inserts a new one, and an insert into a full cache first evicts the key that was used longest ago. With capacity 2, put(1, 10), put(2, 20), get(1) returns 10, then put(3, 30) evicts key 2, so get(2) returns -1.Hash map plus doubly linked listO(1) average per operation timeOpen
- CodingHardAmazonSeveral reportsTrapping Rain WaterEach element of an array is the height of a unit-wide bar, and the bars stand side by side. After rain, water collects in the gaps and cannot spill over a taller wall or past either end of the row; return how many units of water the whole row holds. For heights [3, 1, 0, 2, 0, 5, 1, 4] the answer is 12. The array has up to 100,000 bars, with heights from 0 to 100,000.Two pointersO(n) timeOpen
- CodingMediumAmazonSeveral reportsLongest Palindromic SubstringGiven a string, return its longest substring that reads the same forwards and backwards. If several palindromes tie for the maximum length, return the one that starts earliest, and return an empty string for empty input. For "football" the answer is "oo", because "oo" and "ll" both have length 2 and "oo" starts first. The string has at most 1,000 characters.Expand around the centreO(n²) timeOpen
- Machine codingAmazonSeveral reportsParking lot systemModel a parking lot that has small, medium and large spots. It must let you check whether a spot is available and respect which vehicle types may use which spots. Expect to discuss how the design grows to handle real-world complications.Booking and reservationsSDE-3 (L6); also SDE-1 (L4)Open
- System designMicrosoftSeveral reportsDesign a distributed API rate limiterDesign a rate limiter for a public API served by 50 gateway nodes across three regions. Each API key gets 1,000 requests a minute, the limiter may add at most about 2 ms at p99, and the API must keep working if the limiter's store is down.Counting and limitsSDE-2Open
- System designNetflixSeveral reportsDesign an ad frequency-capping systemDesign the system that makes sure a viewer is shown a given ad campaign at most 3 times a day and 10 times a week, across all their devices. It sits in the ad-selection path, which has a budget of about 10 ms, and must handle about 58,000 ad decisions a second at peak.Counting and limitsL5 (Ads org)Open
- CodingHardUberSeveral reportsAlien DictionaryA list of words is sorted according to the dictionary order of an unknown alphabet. Work out an ordering of the letters that is consistent with the list, or return an empty string if no ordering can exist. For ["wrt","wrf","er","ett","rftt"] the answer is "wertf". Words use lowercase letters, every distinct letter must appear in the answer, and when several orders are valid return the one that is smallest as a string.Topological sort on lettersO(C + V² log V) timeOpen
- Machine codingUberSeveral reportsConcurrent job scheduler with a swappable ordering policyBuild a job scheduler whose code is demonstrable, handles edge cases and stays correct under concurrency and multithreading. Two candidates reported a machine coding round along these lines and neither shared the exact statement, so this answer fixes a concrete scope of its own: delayed start, an ordering rule that can be swapped, cancellation and retries.Schedulers and queuesSDE-2 (L4)Open
- System designAtlassianSeveral reportsDesign a product-agnostic tagging system for several productsDesign a tagging service that several products (issues, wiki pages, code repositories) can share. Users add and remove tags, find items by one or more tags, and get suggestions while typing, and results must respect each product's permissions. Assume 100,000 organizations and 1 billion tagged items.Platforms and searchP40 / SDE-2Open
- CodingMediumAtlassianSeveral reportsDesign Snake GameSimulate the classic snake game on a board with a given width and height. The snake starts as one cell at the top-left corner, and a list of food cells, as [row, column], appears one at a time in the given order. Each move is U, D, L or R, and after a move you return the score, which is the number of foods eaten, or -1 once the game is over because the head left the board or hit the snake's own body. On a 3 wide, 2 high board with food [[1,2],[0,1]], the moves R, D, R, U, L, U return 0, 0, 1, 1, 2, -1. Each move should cost constant time.Deque plus a setO(1) per move timeOpen
- CodingMediumAtlassianSeveral reportsWord Search, right and down moves onlyYou get a grid of letters, given as an array of equal-length strings, and a target word. Decide whether the word can be spelled by a path that starts at any cell and then repeatedly steps one cell right or one cell down, reading one letter per cell. For the grid ["ooo","ozz","eze"] and the word "ooze" the answer is true: start at the top middle o, step right to o, then down to z, then down to e. Moves left and up are not allowed. Assume a grid up to 100 by 100 and a word up to 100 letters.Grid DFS with memoO(m · n · L) timeOpen
- Machine codingAtlassianSeveral reportsRate limiter with pluggable algorithmsDesign a rate limiter for an API. Given requests that carry millisecond timestamps, decide for each one whether it is allowed, for example when a user may send at most two pings per second. Reports describe this both as a short pseudocode design and as a concrete function, so be ready to show a small class design and to compare the algorithms you could plug in.Libraries and infrastructureSDE-2 (off-campus); internship; Principal (Poland)Open
- Machine codingAtlassianSeveral reportsSnake game on a gridDesign a snake game on a rectangular grid where the snake moves one cell at a time by adding a new head and removing its tail. One report links the round to the LeetCode snake game problem, says clarifying questions changed the scope so that leaving the board wraps to the opposite side, and mentions follow-ups on the data structure for the body, on several direction inputs arriving at once and how to synchronise them, and on unit tests. Food, growth and scoring are this answer's assumptions.Games and state machinesSDE-2 (P40); Senior Software EngineerOpen
- System designFlipkartSeveral reportsDesign a BookMyShow-style ticket booking systemDesign an online booking system for movie tickets with reserved seats. On an opening night, 200,000 people chase 300 seats within the first minute; no seat may be sold twice, and a user who picks seats should get a few minutes to pay before they are released.Orders and moneySDE-2Open
- CodingMediumFlipkartSeveral reportsMaximum Points You Can Obtain from CardsA row of cards each shows a number of points. In exactly k moves you take one card per move, always from the left end or the right end of what remains, and your score is the sum of the cards you took. For example, cards [1,2,3,4,5,6,1] with k = 3 give 12, by taking the three cards at the right end: 1, 6 and 5. The row can hold up to 100,000 cards and 1 <= k <= number of cards.Sliding window on the complementO(n) timeOpen
- CodingMediumFlipkartSeveral reportsLongest Substring Without Repeating CharactersGiven a string, return the length of the longest contiguous stretch of it in which no character appears twice. For example, "abcabcbb" gives 3, because "abc" is the longest such stretch. The string may hold letters, digits, symbols and spaces, and can be up to 50,000 characters long.Sliding window with last-seen indexO(n) timeOpen
- System designPhonePeSeveral reportsDesign a Quora-style Q&A platformDesign a question-and-answer site where users post questions, write answers, upvote, follow topics and people, and search for existing questions. Assume 50 million daily users, mostly reading, and pages that should load in under 300 ms.Feeds and rankingSDE-2Open
- CodingMediumPhonePeSeveral reportsSmallest number after removing k digitsGiven a string of digits that represents a non-negative integer and a count k, delete exactly k digits so that the remaining number is as small as possible, and return it as a string with no leading zeros, or 0 if nothing is left. The remaining digits keep their original order. For 1432219 and k = 3 the answer is 1219. The input can have up to 100,000 digits, so the result cannot be handled as a native integer. Two candidate reports list it, one in the data structures round of an SDE interview and one under the second round of an onsite loop in October 2025.Monotonic stack with a deletion budgetO(n) for n digits timeOpen
- CodingHardZomatoSeveral reportsMaximum sum path across two sorted arraysYou are given two arrays of integers, each in strictly increasing order. A path starts at the first element of either array and moves right, and whenever the current value also appears in the other array it may continue in either array from that shared value; a shared value is counted once. The path ends when it runs off the end of the array it is on. Return the largest possible sum of the values on a path, using O(n + m) time and O(1) extra space. For a = [2,4,5,8,10] and b = [4,6,8,9] the answer is 30, from the path 2, 4, 6, 8, 10. Two candidate reports list it, one in the second round of an SDE-2 interview and one in the second round of an SDE-1 backend interview.Two pointers merging sorted arrays with segment sumsO(n + m) for array lengths n and m timeOpen
- CodingMediumGrowwSeveral reportsMinimum Cost For TicketsYou plan to travel on certain days of a year, given as a sorted list of day numbers from 1 to 365. A 1-day pass, a 7-day pass and a 30-day pass cost costs[0], costs[1] and costs[2], and a pass covers that many consecutive days starting on the day you buy it. Return the lowest total cost that covers every travel day. For days [1,4,6,7,8,20] and costs [2,7,15] the answer is 11.1D dynamic programmingO(D), D at most 365 timeOpen
- System designDream11Several reportsNotify users about their lineup 30 minutes before a matchDesign a service that sends each user who has entered a fantasy contest a reminder 30 minutes before the match starts, with their lineup status. On the busiest match about 5 million users have entered, several matches can overlap, and the start time can move.Streams and jobsSDE-2Open
- System designMyntraSeveral reportsDesign a review-based feed with caching, push and pullDesign a feed where shoppers scroll through product reviews and style posts from people and brands they follow, mixed with popular reviews from categories they browse. Assume 20 million daily users who open the feed 10 times a day, and some brand accounts with 5 million followers.Feeds and rankingsenior SDEOpen
- CodingHardMyntraSeveral reportsLongest increasing path in a matrixGiven a grid of integers, find the length of the longest path in which every step moves up, down, left or right to a cell holding a strictly larger value. A path may start in any cell and may not leave the grid, and the answer counts the cells on the path. For [[9,9,4],[6,6,8],[2,1,1]] the answer is 4, from the path 1, 2, 6, 9. The grid can have a few hundred rows and columns. Two candidate reports about a year apart mention it, and one candidate started from plain depth-first search and added memoisation when pushed.Topological layers on an implicit DAGO(m * n) for an m by n grid timeOpen
- Machine codingMyntraSeveral reportsOnline store with direct and instalment paymentsBuild the back end of a small online store that lives entirely in memory. Admins add products from the console, from a file or from an external feed, and users browse and buy. A user can pay straight through a payment gateway or in instalments within a personal credit limit that depends on their past payments. Payment methods are expected to change, so adding one should not mean rewriting checkout.Wallets and paymentsSenior Software Engineer (about 5 years of experience)Open
- System designGoogleOne reportDesign a distributed counterDesign a service that counts events such as views or likes for 100 million items. Increments arrive at up to 58,000 a second across all items, one viral item can briefly take 20,000 a second, and a read should be within a few seconds of the truth and never go backwards.Counting and limitsL5Open
- System designGoogleOne reportDesign a URL shortenerDesign a service that turns long URLs into short links and redirects visitors to the original. Assume 10 million new links a day, about 100 redirects for every link created, links that live for years, and a redirect that should feel instant for users around the world.Counting and limitsSDE-2Open
- System designGoogleOne reportDesign the job-alert feature of a careers siteA careers site lets people save a search (keywords, location, level, remote or not) and get an email when a matching job is posted. Design the alert feature for about 5 million saved alerts and tens of thousands of new or changed jobs a day, with no duplicate emails and a one-click unsubscribe.Streams and jobsL5Open
- FundamentalsMany companiesOne reportComputer networks: 20 reported questionsNetworking questions reported in interviews: layers, DNS, HTTP, load balancing and TLS, with model answers. Open a theme, try the answer aloud first, then check it against the model.Computer networksOpen
- System designMetaOne reportDesign a game leaderboard (top-K ranking)Design a leaderboard for an online game with 50 million players. It shows the global top 100, tells any player their exact rank, and reflects a finished match within a few seconds.Feeds and rankingE5Open
- System designMetaOne reportDesign a LeetCode-style coding platformDesign an online platform where users read a problem, submit code in several languages, and get a verdict from hidden test cases. Assume 1 million daily active users and a weekly contest with 100,000 participants over two hours.Platforms and searchOpen
- System designAmazonOne reportDesign a shopping system that survives a big sale eventDesign the shopping stack for an e-commerce site that must survive a big sale: traffic jumps 20 times, a few hundred popular items have limited stock, and checkout has to keep working even if recommendations or reviews fail.Counting and limitsSDE-2Open
- System designAmazonOne reportDesign a toll fare system with Kafka streamingDesign a toll fare system where roadside gantries read vehicle tags, a Kafka-based streaming pipeline pairs entry and exit reads into trips, prices each trip by distance, vehicle class and time of day, and charges the account. Reads can arrive late, duplicated or out of order, and nobody may be charged twice.Streams and jobsSDE-2 / L5Open
- Machine codingAmazonOne reportElevator system with priority schedulingDesign the classes and public methods of an elevator system for a building, and explain what each class is responsible for. The reported follow-up is to schedule requests by priority.Schedulers and queuesSDE-2 (L5)Open
- System designMicrosoftOne reportDesign a real-time collaborative document editorDesign a document editor where several people edit the same document at the same time. Each person's edits should appear for the others within a fraction of a second, no one's edits may be lost, and every client must end up with an identical document. Assume up to 100 collaborators on a document but usually 2 to 5.Chat and real timeSDE-2 (L61)Open
- CodingMediumMicrosoftOne reportPopulating Next Right Pointers in Each NodeTake a perfect binary tree given as a level-order array: every parent has two children and every leaf sits at the same depth. Set each node's next pointer to the node immediately to its right on the same level, or null for the last node of a level. To make the result checkable, the function returns the values reached by following next pointers level by level, with the string "#" ending each level, so [1,2,3,4,5,6,7] gives [1,"#",2,3,"#",4,5,6,7,"#"]. Aim for constant extra space, not counting the tree itself.Tree BFS by levelO(n) timeOpen
- CodingEasyMicrosoftOne reportRelative Sort ArrayYou get two integer arrays, arr1 and arr2, where the values of arr2 are distinct and every one of them also appears in arr1. Reorder arr1 so the values named in arr2 come first, following arr2's order with all copies of a value together, and the remaining values follow in ascending order. For arr1 = [5,3,1,3,5,5,8,2] and arr2 = [5,1] the result is [5,5,5,1,2,3,3,8]. Lengths are about a thousand and values are small, but your solution should stay correct for any integers.Counting with a hash mapO(n + m + r log r) timeOpen
- Machine codingMicrosoftOne reportThread pool with a queue, a thread cap and idle releaseBuild a thread pool from scratch that runs submitted tasks in parallel, puts extra tasks in a queue without priorities when every thread is busy, never exceeds a maximum number of threads and releases threads that have no work instead of leaving them idle. The report mentions follow-up questions on synchronized and volatile, so this answer also explains what a real threaded version needs.Schedulers and queuesSoftware Engineer (L60)Open
- Machine codingMicrosoftOne reportLogger that reports finished processes in start order in constant timeDesign a logger with start, end and log operations. Processes start and end in any order, and log must report the finished processes that started before every process that is still running, without scanning all processes, so each operation takes constant time. A follow-up asks how new logging behaviour can be added without changing the core code.Libraries and infrastructureSenior Software Engineer (L63)Open
- System designAppleOne reportDesign a GitHub-like code hosting service (load balancing and observability)Design a code hosting service that supports git clone, fetch and push over HTTPS and SSH, plus a web interface and an API. Focus on how traffic is spread across servers and how you would know the service is healthy, for roughly 10 million users and 10 million repositories.Platforms and searchSenior (ICT3 offer, SRE loop)Open
- System designNetflixOne reportDesign a scheduler for ML training and batch jobs on a shared clusterDesign a scheduler that runs ML training jobs and batch data jobs on one shared cluster of a few thousand GPU and CPU machines. Teams have quotas, some jobs need many GPUs at once, urgent jobs must be able to jump the queue, and machines fail every day.Streams and jobsOpen
- CodingHardNetflixOne reportMerge k Sorted ListsYou receive k sorted lists of integers, any of which may be empty, and must combine them into one sorted list. For [[1,4,5],[1,3,4],[2,6]] the result is [1,1,2,3,4,4,5,6]. The total number of values N and the number of lists k can each reach about 10,000, so repeatedly scanning all k list fronts for every output value costs about N times k steps, which is wasteful and grows quickly. In the original problem each list is a chain of linked nodes that the answer should reuse; here the lists arrive as arrays, are turned into chains, and the merged chain is read back as an array.Min-heap mergeO(N log k) timeOpen
- System designUberOne reportDesign a top-k popularity ranking systemDesign a system that returns the 50 most popular items in a city over the last hour, refreshed every minute, from a stream of order or view events that peaks near 58,000 a second. Reads come from a mobile app and must be fast.Feeds and rankingL4 / SDE-2Open
- System designUberOne reportDesign a Messenger-style chat appDesign a chat service that supports one-to-one conversations and small groups for 100 million concurrent connections. Messages should arrive in under 500 ms when the recipient is online, be delivered later when they are offline, keep a scrollable history, and show sent, delivered and read states.Chat and real timeSDE-2 / L4 (India)Open
- Machine codingUberOne reportMulti-device controllerDesign an application that controls several kinds of device, for example a fan and a television. Some commands apply to every device and some belong to one device type. The brief is loose, so part of the task is deciding which commands exist and whether the set of devices is known up front.Libraries and infrastructureSDEOpen
- CodingMediumAtlassianOne reportLongest Consecutive SequenceGiven an unsorted array of integers, return the length of the longest run of consecutive integers, where the numbers may appear anywhere in the array and in any order. For [100,4,200,1,3,2] the answer is 4, because 1, 2, 3 and 4 are all present. Duplicates count once, negative numbers and zero are allowed, and the array may be empty. Aim for linear time on arrays of up to a million values.Hash set, count from run startsO(n) average timeOpen
- System designFlipkartOne reportDesign a ledger that stores transactions from many servicesDesign a central ledger that orders, wallet, refund and payout services all write transactions to. No entry may be lost or counted twice, balances must be readable in real time, and an auditor must be able to rebuild any account's history.Orders and moneySDE-2Open
- System designFlipkartOne reportDesign a daily-essentials subscription serviceDesign a subscription service where customers get milk, bread or similar items delivered each morning on a schedule they choose (daily, alternate days, weekdays). Support pause, skip and quantity changes, handle payment, and scale to 2 million active subscriptions.Orders and moneySDE-2Open
- CodingMediumFlipkartOne reportHouse RobberA street has houses in a row, each holding some cash, and you may take from any set of houses as long as no two are neighbours. Given the amounts in order, return the most you can take. For example, [2,7,9,3,1] gives 12, by taking from the houses holding 2, 9 and 1. There are up to 100 houses and every amount is zero or more.1D dynamic programmingO(n) timeOpen
- CodingHardFlipkartOne reportFewest Energy Drinks to Finish a MarathonA runner starts a marathon with reserve calories of energy and burns perMile calories for every mile. Along the course there are checkpoints, and each one holds a single energy drink worth a known number of calories. The array gaps lists the miles from the start to the first checkpoint, then between each pair of checkpoints, then from the last checkpoint to the finish, so it has one more entry than the array drinks. The runner may take a drink only at a checkpoint that has been reached, takes the whole drink, and must never run out of energy before reaching the next point, although arriving with exactly zero is fine. Return the fewest drinks that get the runner to the finish, or -1 if it cannot be done. For reserve 10, perMile 1, gaps [10,10,10,30,40] and drinks [60,30,30,40] the answer is 2. There are up to 100,000 checkpoints.Greedy with a max-heapO(n log n) timeOpen
- Machine codingFlipkartOne reportScheduling M jobs on N threads under four policiesSchedule M jobs across N threads on one machine. Each job has a name, a duration, a priority where P0 is the highest, a deadline and a submitter type (root, admin or user). Implement shortest job first, first come first served, fixed priority and earliest deadline first, with the tie-break rules the report lists, print the order of jobs on each thread, and skip a job under the deadline policy when it cannot finish in time. Expect the requirements to change once the first version works.Schedulers and queuesSDE-1 (experienced)Open
- Machine codingFlipkartOne reportInterviewer allocationInterviewers and interviewees each register for one of two interview types and list the time slots they prefer, and the system pairs them by type and slot. The code should be object oriented, easy to extend with a new interview type or a new slot, ready to demonstrate, and clear about errors such as a slot outside the allowed range.Matching enginesSDE-2Open
- System designSwiggyOne reportDesign a promotional offer notification systemDesign a system that lets marketing send a promotional offer to a segment of tens of millions of users by push, SMS or in-app message, at a chosen local time, with per-user frequency limits and an offer that expires. Opted-out users must never receive it, and a sudden rush of app opens must not take the ordering backend down.Streams and jobsSDE-3 (L8)Open
- CodingMediumSwiggyOne report3SumGiven an array of integers, find every distinct triple of values that adds up to zero, using three different positions in the array. List each triple in ascending order and the triples in ascending order too, so the answer is unique, and never list the same triple twice even if its values occur several times. For example, [-1,0,1,2,-1,-4] gives [[-1,-1,2],[-1,0,1]]. The array has up to 3,000 numbers.Sort and two pointersO(n²) timeOpen
- CodingMediumSwiggyOne reportMin StackDesign a stack that supports push, pop, top and getMin, where getMin returns the smallest value currently in the stack, and every operation runs in constant time. For example, after pushing -2, 0 and -3, getMin returns -3; after one pop, top returns 0 and getMin returns -2. Pop, top and getMin are only ever called on a non-empty stack, and there can be tens of thousands of operations.Stack with a running minimumO(1) per operation timeOpen
- CodingMediumSwiggyOne reportTask SchedulerA processor runs one task per time slot or sits idle, and each task is a capital letter that may run in any order. Two runs of the same letter must have at least n other slots (tasks or idle) between them, and you return the fewest slots needed to finish all tasks. For example, tasks ["A","A","A","B","B","B"] with n = 2 need 8 slots: A B idle A B idle A B. There are up to 10,000 tasks.Greedy counting or max-heapO(T) timeOpen
- CodingMediumSwiggyOne reportMinimum Days to Make m BouquetsFlowers stand in a row, and bloomDay[i] is the day flower i opens. A bouquet needs exactly k flowers that are next to each other in the row and all open, and each flower can go into at most one bouquet. Return the earliest day on which you can have m bouquets, or -1 if the row is too short. For bloomDay [1,10,2,9,3,8,4,7,5,6], m = 4 and k = 2 the answer is 9. The row holds up to 100,000 flowers and days go up to a billion, so trying day after day is far too slow.Binary search on the answerO(n log D), D is the range of bloom days timeOpen
- Machine codingSwiggyOne reportSnake and ladder board gameImplement the board game snake and ladder in an object-oriented way. The basic rules must work, and extra requirements are to be supported by extension: any board size, any number of players, a ladder that begins where a snake ends, a snake that begins where a ladder ends, and play that continues until every player has finished.Games and state machinesSDE-1 (backend)Open
- Machine codingSwiggyOne reportMeeting calendar applicationBuild a calendar application that schedules meetings, shows each user's calendar, and lets invitees accept or reject. The report lists seven requirements, not all of which are readable, and the code had to run cleanly at the end, so the answer states the assumed requirements.Booking and reservationsSDE-1Open
- CodingMediumRazorpayOne reportRotting OrangesA grid holds 0 for an empty cell, 1 for a fresh orange and 2 for a rotten one, and every minute each fresh orange that touches a rotten one (up, down, left or right) becomes rotten. Return the number of minutes until no fresh orange is left, or -1 if some orange can never rot. For [[2,1,1],[1,1,0],[0,1,1]] the answer is 4. The grid can be as large as 1,000 by 1,000.Multi-source grid BFSO(R×C) timeOpen
- CodingMediumRazorpayOne reportMake Sum Divisible by PGiven an array of positive integers nums and an integer p, remove the shortest contiguous subarray (it may be empty, but it cannot be the whole array) so that the sum of the remaining elements is divisible by p. Return the length of the removed subarray, or -1 if no valid removal exists. For nums = [3,1,4,2] and p = 6 the answer is 1, by removing [4]. The array can hold 100,000 numbers, each up to 1,000,000,000.Prefix sums with remaindersO(n) on average timeOpen
- CodingMediumRazorpayOne reportFind the Duplicate NumberAn array nums holds n + 1 integers, each between 1 and n inclusive, and exactly one value is repeated (possibly many times). Return it without modifying the array and using only constant extra space. For [1,3,4,2,2] the answer is 2. The array can have up to 100,000 elements.Cycle detectionO(n) timeOpen
- CodingMediumRazorpayOne reportMinimum Meeting RoomsMeetings are given as [start, end] pairs with the start before the end, in no particular order. Two meetings clash when they overlap in time, and a meeting that ends at the very moment another begins does not clash with it. Return the fewest rooms that can hold all the meetings. For [[0,30],[5,10],[15,20]] the answer is 2. There are up to 100,000 meetings and times go up to two billion.Sorted starts and endsO(n log n) timeOpen
- Machine codingRazorpayOne reportIn-memory databaseBuild a small in-memory database as a machine-coding exercise. The reported brief gives no schema or query detail, so assume tables with typed columns, insert, select, update and delete with simple filters, and one index that speeds up equality lookups. Bad input should fail with a clear error and leave the stored data unchanged.Caches and storesOpen
- Machine codingRazorpayOne reportLoad balancer with round robinBuild a load balancer that exposes HTTP endpoints, uses them to call an external service, and demonstrates round-robin distribution of the requests.Libraries and infrastructurePrincipal Software EngineerOpen
- System designPhonePeOne reportDesign a web-scale search engine (crawler and query service)Design a web search engine with a crawler that collects pages and a query service that returns ranked results in under 300 ms. Assume 10 billion pages indexed, 5,000 queries a second at peak, and every page refreshed about once a month.Platforms and searchSDE-2Open
- CodingMediumPhonePeOne reportDistribute Coins in Binary TreeA binary tree has N nodes and holds exactly N coins in total, spread over the nodes (some may hold none). In one move you pass one coin between two nodes joined by an edge. Return the minimum number of moves so every node holds exactly one coin. The tree is a level-order array with null for missing children, and [0,3,0] needs 3 moves; there are up to 100 nodes.Post-order tree DFSO(N) timeOpen
- CodingMediumPhonePeOne reportMinimum Speed to Arrive on TimeYou take n trains in order, all at the same integer speed in km per hour, and dist[i] is the length of the i-th ride. A train departs only on a whole hour, so after each ride except the last you wait for the next whole hour. Given the allowed total time hour (at most two decimal places), return the smallest positive integer speed that arrives in time, or -1 if none does. For dist = [2,4,7,3] and hour = 6.5 the answer is 4. There can be 100,000 rides, each at most 100,000 km, and hour is at most 100.Binary search on the answerO(n log V) timeOpen
- Machine codingPhonePeOne reportMovie ticket booking systemDesign an object-oriented movie ticket booking system, organised into entity, service and repository layers, and write tests for it. The sources do not state concurrency requirements, so the answer treats seat holds and conflicting bookings as the central design question and states that assumption.Booking and reservationsSDE-2 (per post title)Open
- Machine codingPhonePeOne reportMulti-level cache with pluggable evictionBuild a cache made of several levels, each with its own fixed capacity, holding string keys and values. A read searches from the top level downward and promotes a hit to the top. A write pushes whatever it evicts down to the next level, and a new level is created on demand up to a configured maximum. A delete removes the key from every level. The eviction rule must be pluggable, with least frequently used required.Caches and storesOpen
- CodingMediumZomatoOne reportShortest path with DijkstraA network has nodes labelled 1 to n, and each directed edge [from, to, time] says a signal sent from one node reaches the other after that many time units. A signal starts at node k and travels along every outgoing edge at once; return how long it takes until every node has received it, or -1 if some node is never reached. For times [[1,2,1],[1,3,5],[2,3,2],[3,4,1]], n = 4 and k = 1 the answer is 4. Times are non-negative, and there can be tens of thousands of nodes and about 100,000 edges.Dijkstra with a min-heapO(E log E) timeOpen
- Machine codingZomatoOne reportDeck of cardsModel a deck of playing cards. Each card has one of four suits and a colour, and the deck must support popping the top card, shuffling, and dealing cards to every player. Expect a small, clean object design where the shuffle can be tested.Games and state machinesSDE-1 (fresher)Open
- System designCREDOne reportDesign a Dropbox-style file storage and sync serviceDesign a service where users keep files in a folder that syncs across their laptop and phone. Assume 10 million users, files of a few MB, and edits from two devices that can happen offline. Large files should upload in pieces and resume after a drop.Platforms and searchSDE-2Open
- CodingHardCREDOne reportWildcard pattern matching with ? and *Given a text and a pattern, decide whether the pattern matches the entire text. In the pattern, ? stands for exactly one character, * stands for any run of characters including the empty run, and every other character matches only itself. For example, the text adceb matches the pattern *a*b, while the text acdcb does not match a*c?b. Both strings can be a few thousand characters long. A candidate report lists it among the problems of a long online coding round for an intern role.Prefix table DP, rolled to one rowO(n * m) for text length n and pattern length m timeOpen
- CodingHardCREDOne reportSettle group expenses with the fewest paymentsA group has recorded who handed money to whom: each record [from, to, amount] says that person from handed a positive whole amount to person to, so the receiver owes it back. Find the smallest number of payments that settles everyone, where a payment may move any amount between any two people. For example, the records [[0,1,10],[2,0,5]] mean person 1 owes 10 to person 0 and person 0 owes 5 to person 2, so the best settlement takes 2 payments: person 1 pays 5 to person 0 and 5 to person 2. A candidate report lists it as a face-to-face design question, minimising the give and take in an app like Splitwise, where each user adds what they spend and it is shared equally. This version takes the debts as who-owes-whom records, the usual form of the problem. Assume at most about a dozen people end up with a non-zero balance.Backtracking over net balancesO((n-1)!) worst case for n non-zero balances, far less after pruning timeOpen
- CodingMediumCREDOne reportKth character of a repeat-encoded stringAn encoded string is a list of blocks, each block being some letters followed by a whole number that says how many times those letters repeat, so ab3c2 decodes to abababcc. Given the encoded string and a 1-based position k, return the character at position k of the decoded string, or an empty string when k falls outside it, without building the decoded string. The reported statement writes a count after every block (even a count of 1), allows counts of several digits, and may split one run into parts such as a2a2b3b1; here a block with no number counts once. The decoded string can be far longer than the encoded one. A candidate report lists it in an online test, where the candidate simply decoded the string; avoiding that is the stronger answer.One pass over run-length blocks with index arithmeticO(n) for an encoded string of length n timeOpen
- CodingMediumCREDOne reportIn-memory contact manager with prefix searchBuild an in-memory contact manager. add(firstName, lastName, phone) stores a contact and returns its numeric id, starting at 1. remove(id) deletes a contact and returns whether it existed. search(prefix) returns every contact whose first name, last name or phone number starts with the prefix, ignoring case, each shown as first name, last name and phone separated by spaces, in the order the contacts were added. A contact that matches through more than one field appears once, and an empty prefix returns nothing. The per-search cost should depend on the prefix length and the number of matches, not on the number of contacts. A candidate report lists it as a machine coding round: add or update contacts, then search by first name, last name or phone number, partial or complete and case insensitive, with the total count shown, in memory only and checked by unit tests. This version merges the three searches into one that matches any of the fields, and has remove in place of update.Trie whose nodes hold the ids passing throughO(L) for add and remove of keys with total length L, O(p + r) for search timeOpen
- Machine codingCREDOne reportPayment-processing module with errors and testsImplement the key features of a payment-processing package in object-oriented code. The work is judged on the design patterns it uses, its error handling and its test coverage, and the tests must run without calling a real payment provider.Wallets and paymentsSDE-2Open
- CodingHardMeeshoOne reportMaximum Profit in Job SchedulingYou get n jobs, each with a start time, a later end time and a profit; a set of jobs can be done only if no two overlap, though a job may start exactly when another ends. Return the largest total profit you can collect. For starts [1,2,3,3], ends [3,4,5,6] and profits [50,10,40,70] the answer is 120, from the first and last jobs. There can be 50,000 jobs and times up to a billion, so a table indexed by time is not an option.Sort, DP and binary searchO(n log n) timeOpen
- CodingEasyMeeshoOne reportActivity SelectionYou are given the start and finish times of n unsorted activities, each starting before it finishes, and a single room, and you must pick as many activities as possible with no two overlapping; an activity may start at the moment another one finishes. Return how many you can pick. For starts [1,3,0,5,8,5] and finishes [2,4,6,7,9,10] the answer is 4, for example (1,2), (3,4), (5,7) and (8,9). The value of n can be several hundred thousand.Greedy by earliest finishO(n log n) timeOpen
- Machine codingMeeshoOne reportCar pooling systemDesign and build a working car pooling system within about an hour. The interviewer reportedly looked at the overall approach, the design of classes and modules, and whether the code was clean and executable.Matching enginesSDE-1 (open campus)Open
- Machine codingMeeshoOne reportInventory service with stock blockingDesign an inventory service that can add a product, add stock, block stock for an order and handle the outcome of the payment. Blocked stock cannot be sold to anyone else. When the payment succeeds the blocked stock is consumed, and when it fails the stock goes back to being available.Booking and reservationsSDE-3Open
- CodingHardGrowwOne reportLongest Valid ParenthesesGiven a string made only of the characters ( and ), return the length of the longest contiguous substring that is a balanced run of parentheses, where every opening bracket is closed in the right order. For the string )()()) the answer is 4, from the substring ()(). The string can be 30,000 characters long, so checking every substring is too slow.Stack of indicesO(n) timeOpen
- Machine codingGrowwOne reportVending machine with object-oriented designDesign a vending machine using object-oriented design. The report says only that various parameters were given and does not list them, so this answer fixes its own scope: products in coded slots with a price and a quantity, cash in whole units, change from a limited float, and a separate state for each situation the machine can be in.Games and state machinesInternship (year not stated)Open
- CodingMediumPaytmOne reportZero-Sum SubarraysGiven an array of integers that may contain negatives and zeros, count the contiguous, non-empty subarrays whose elements add up to exactly 0. Two subarrays at different positions count separately even when their values match. For [4,-4,1,-1,3] the answer is 3, from [4,-4], [1,-1] and [4,-4,1,-1]. The array can hold up to 100,000 values, each between -10^9 and 10^9 in size.Prefix sums with a hash mapO(n) average timeOpen
- CodingMediumPaytmOne reportClosest Pair to a Target in a Sorted ArrayYou get an array of integers sorted in ascending order and a target number. Pick two different positions whose values add up as close to the target as possible and return those two values as [smaller, larger], breaking ties by the smaller sum, then the smaller first value, and returning [] when there are fewer than two elements. For [2,5,9,14,20] and target 17 the answer is [2,14], because 16 is only 1 away. The array can hold up to 100,000 values.Two pointersO(n) timeOpen
- System designOlaOne reportShow nearby cabs for riders inside a cityDesign the feature that shows nearby available cabs on a rider's map. Assume 100,000 drivers online in the busiest city, each reporting a location every 4 seconds, and 150,000 riders with the map open. Also decide whether a pickup point lies inside a defined zone, such as an airport area.Chat and real timeSDE-2Open
- CodingMediumOlaOne reportStack with popMin and popMaxDesign a stack of numbers with push, pop, top, peekMin, peekMax, popMin and popMax, driven as an operation list: run(ops, args) applies each operation with its own argument list and returns one result per operation. pop and top use the most recent surviving push; popMin and popMax remove and return the smallest or largest value, taking the copy nearest the top when values tie; push, and every operation on an empty stack, return null. For push 5, push 1, push 5, peekMax, popMax, top, popMin, pop the results are [null,null,null,5,5,1,1,5]. Up to 100,000 operations are run in order.Two ordered views of one stackO(log n) amortized per operation timeOpen
- CodingMediumOlaOne reportMinimum Cost to Connect RopesYou have a list of rope lengths and keep joining two ropes at a time until one rope remains, where a join costs the sum of the two lengths and leaves one rope of that combined length. Return the smallest possible total cost, or 0 when there are fewer than two ropes. For [4,3,2,6] the answer is 29: join 2 and 3 for 5, then 4 and 5 for 9, then 6 and 9 for 15. The list can have 100,000 ropes with lengths up to 10,000.Min-heapO(n log n) timeOpen
- Machine codingOlaOne reportTopic-based publish-subscribe with consumer groupsBuild a system where many senders publish events to named topics and many receivers subscribe to topics, so that every event on a topic reaches every subscriber. As a bonus, support receiver groups where each group gets every event once and only one member of the group handles it, in the way Kafka consumer groups behave.Schedulers and queuesSDE-2Open
- Machine codingOlaOne reportLogging library with pluggable outputsDesign and implement a logging library that application code calls to record messages. Messages can go to several outputs at once, such as a file, a network target or a database, and adding an output should be easy. The message format is configurable, the library should add little overhead for the caller, and the follow-up discussion covers how it handles concurrency.Libraries and infrastructureSDE-2Open
- CodingMediumDream11One reportMinimum Path SumA grid of non-negative integers is given, and you travel from the top-left cell to the bottom-right cell, moving only right or down and adding the value of every cell you stand on, including the first and the last. Return the smallest possible total. For [[2,1,3],[4,8,1],[7,2,1]] the answer is 8, using the path 2, 1, 3, 1, 1. The grid can be up to 200 by 200.2D dynamic programmingO(R×C) timeOpen
- CodingHardDream11One reportFirst Missing PositiveGiven an unsorted array of integers, return the smallest positive integer (1, 2, 3, and so on) that does not appear in it. It must run in linear time with only a constant amount of extra memory beyond the array, and you may rearrange the array while you work. For [5,2,-1,1,3,3] the answer is 4. The array can hold 100,000 values, including negatives, zeros, repeats and huge numbers.In-place hashing by indexO(n) timeOpen
- CodingHardJuspayOne reportLock and Unlock Nodes in an N-ary TreeDesign a LockTree over n nodes numbered 0 to n-1, built from a parent array in which the single root has parent -1 (node 0 in the example below). lock(node, user) returns true and locks the node only if the node is unlocked and none of its ancestors and none of its descendants is locked, and unlock(node, user) returns true and frees the node only if that same user locked it; otherwise a call returns false and changes nothing. The input is an operation list like a LeetCode design problem: run(ops, args) returns null for the constructor "LockTree" and a boolean for every later call, so with parent [-1,0,0,1,1,2] the calls lock(1,7), lock(3,8), unlock(1,8) return true, false (ancestor 1 is locked), false (wrong user). There are up to 100,000 nodes and calls, user ids are positive integers, and the tree height stays under 1,000.Tree with ancestor and descendant countersO(h) per call, h = tree height timeOpen
- CodingMediumJuspayOne reportConstruct Binary Tree from Inorder and PostorderYou are given the inorder and the postorder traversal of the same binary tree, where all values are distinct. Rebuild the tree and return it as a level-order array, writing null for a missing child and dropping trailing nulls. For inorder [9,3,15,20,7] and postorder [9,15,7,20,3] the answer is [3,9,20,null,null,15,7]. There are up to 3,000 nodes, and an empty tree gives an empty array.Divide and conquer with an index mapO(n) timeOpen
- CodingMediumMyntraOne reportMaximum Overlapping IntervalsGiven a list of closed integer intervals [start, end] with start never above end, return the largest number of intervals that contain one common point. Intervals that only touch, like [1,4] and [4,6], do share that point. For [[1,4],[2,5],[9,12],[5,9],[5,12]] the answer is 3, because the point 5 lies in [2,5], [5,9] and [5,12]. There are up to 100,000 intervals, they come in no particular order, and an empty list gives 0.Sweep line over start and end eventsO(n log n) timeOpen
- CodingMediumMyntraOne reportFirst Non-Repeating Character in a StreamCharacters arrive one at a time. After each arrival, report the first character that has appeared exactly once so far, or # if no character is unique, and return all the reports joined into one string. For the stream "mamas" the answer is "mma#s". There are up to 100,000 characters, and each report must be cheap because the stream never stops.Queue plus countsO(n) timeOpen
- System designMetaPrep guidesDesign an Instagram-style ranked feedDesign the home feed for a photo and short-video sharing app with 500 million daily users. Posts from accounts a user follows should show up within seconds, the feed should be ranked per viewer rather than purely newest-first, and a feed load should finish in under 300 ms.Feeds and rankingOpen
- System designMicrosoftPrep guidesDesign a firmware-update delivery systemDesign a system that delivers firmware updates to 50 million connected devices. Updates are tens of megabytes, devices have unreliable networks, a bad update must be stoppable and recoverable, and only genuine updates may be installed.Platforms and searchSDE-2Open
- CodingMediumMicrosoftCompany listsLongest Repeating Character ReplacementGiven a string s of uppercase letters and an integer k, you may change any character to any other uppercase letter at most k times in total. Return the length of the longest substring that can be made of one repeated letter. For s = "AABABBA" and k = 1 the answer is 4, for example by turning the single B in "AABA" into an A. The string can have up to 100,000 characters, so checking every substring is too slow.Sliding windowO(n) timeOpen
- System designApplePrep guidesDesign an iMessage-style messaging backendDesign a messaging backend where each user has several devices, message contents are end-to-end encrypted so the servers cannot read them, and a message sent while a device is offline is delivered when it comes back. The service runs in more than one region.Chat and real timeOpen
- CodingMediumAppleCompany listsTop K Frequent ElementsGiven an array of integers and a number k, return the k distinct values that appear most often, in increasing order. The input is guaranteed to have a unique answer, so there is no tie at the cutoff. For nums [7, 2, 7, 5, 2, 7] and k = 2 the answer is [2, 7], because 7 appears three times and 2 appears twice. The array has up to 100,000 elements, and the selection should not sort every distinct value.Heap or bucket sort over countsO(n) plus O(k log k) to sort the output timeOpen
- CodingMediumAppleCompany listsIs Graph Bipartite?An undirected graph has nodes numbered 0 to n - 1 and is given as an adjacency list, where graph[i] holds the neighbours of node i. Decide whether the nodes can be split into two groups so that every edge joins a node of one group to a node of the other. For graph [[1, 2], [0, 2], [0, 1, 3], [2]], a triangle with a tail, the answer is false. The graph may be disconnected and has up to 10,000 nodes.Graph two-colouring with BFSO(V + E) timeOpen
- CodingMediumAppleCompany listsNumber of IslandsA grid holds 1 for land and 0 for water. An island is a group of land cells joined through shared sides (up, down, left or right, never diagonally), and you must return how many islands the grid contains. For the grid [[1, 1, 0, 0], [0, 1, 0, 1], [1, 0, 0, 1]] the answer is 3. The grid is a rectangle of up to 300 rows and 300 columns.Grid DFS or BFSO(m · n) timeOpen
- CodingMediumNetflixCompany listsTime Based Key-Value StoreDesign a store that keeps every value ever written for a key together with the time of the write. set(key, value, timestamp) records a value, and get(key, timestamp) returns the value with the largest timestamp not after the one asked for, or an empty string if there is none. Timestamps for one key only increase, and there can be 200,000 calls, so a read must not scan the whole history. Example: after set("a","x",10) and set("a","y",20), get("a",15) is "x", get("a",5) is "", and get("a",25) is "y".Hash map and binary searchset O(1), get O(log m) timeOpen
- CodingMediumNetflixCompany listsCourse Schedule IIThere are numCourses courses labelled 0 to numCourses - 1, and each pair [a, b] means course b must be finished before course a. Return an order in which all courses can be taken, or an empty list if the pairs contain a cycle and no order exists. For numCourses = 5 and pairs [[1,4],[2,4],[3,1],[3,2],[0,3]] one valid order is [4,1,2,3,0]. Any valid order is correct in an interview, so the reference here is deterministic: it starts with free courses in increasing label order and visits each course's dependants in the order the pairs were given.Topological sortO(V + E) timeOpen
- System designUberPrep guidesDesign a ride-hailing dispatch system with surge pricingDesign a ride-hailing dispatch system: a rider requests a trip, the system finds a nearby available driver and offers the trip, and the price rises with a surge multiplier where demand exceeds supply. Assume hundreds of thousands of drivers online at peak, each reporting a location every few seconds.Chat and real timeOpen
- CodingHardUberCompany listsNumber of Islands IIA grid with m rows and n columns starts as all water. You are given a list of cells that turn into land one at a time. After each addition, report how many islands exist, where an island is a group of land cells joined up, down, left or right. On a 3 by 3 grid, adding (0,0), (0,1), (1,2), (2,1), (1,1) gives [1,1,2,3,1]. A cell can appear twice, and adding land that is already land changes nothing. Assume up to 100,000 additions on a grid with up to a million cells.Union-find with online updatesO(k · α(k)) timeOpen
- CodingHardUberCompany listsBus RoutesEach bus follows a route, a list of stops it visits in a loop forever. You start at one stop and want to reach another using as few different buses as possible, changing buses at any stop shared by two routes. Return the minimum number of buses, or -1 if the target cannot be reached. For routes [[1,2,7],[3,6,7]], start 1 and target 6, the answer is 2: ride the first bus to stop 7, then the second bus to stop 6. Assume up to 500 routes, 100,000 stop entries in total, and stop numbers below one million.BFS over routesO(S) timeOpen
- System designAtlassianPrep guidesDesign an engagement-based popular content feedDesign a feed that shows the most popular content in an organization, ranked by recent engagement such as views, reactions and comments. Assume 100 million engagement events a day, 5 million users, and a feed that should reflect activity within a few minutes.Feeds and rankingP40Open
- System designSwiggyPrep guidesSplit a mixed order into child orders under one parent orderA customer checks out one cart containing a restaurant meal and groceries from a separate warehouse. Design how the system splits it into child orders under a single parent, with one payment, independent fulfilment of each child, and sensible handling when one child is rejected or cancelled.Orders and moneySDE-2 (backend)Open
- System designRazorpayPrep guidesDesign a subscription billing platform on top of a payments systemDesign a subscription billing platform that sits on top of an existing payments system. It needs plans with monthly and yearly prices, free trials, mid-cycle upgrades and downgrades, retries for failed payments, and invoices, for 5 million subscriptions.Orders and moneySDE-2 and aboveOpen
- System designRazorpayPrep guidesDesign a distributed job schedulerDesign a service where other teams register jobs to run at a given time or on a recurring schedule, and it calls them back reliably. Assume about 100 million registered jobs, 10 million executions a day, and bursts at round times such as midnight.Streams and jobsSDE-2 and aboveOpen
- CodingMediumPhonePeCompany listsMost Stones Removed with Same Row or ColumnStones sit on distinct integer grid points, given as [row, col] pairs. A stone can be removed if another stone that has not been removed yet shares its row or its column. Return the largest number of stones that can be removed; for [[0,0],[0,2],[1,1],[2,0],[2,2]] the answer is 3. There can be 1,000 stones with coordinates up to 10,000.Union-find on rows and columnsO(n α(n)), near linear timeOpen
- System designZomatoPrep guidesDesign live order tracking for a food delivery appDesign the live tracking screen for a food delivery app: the customer sees the order status and the rider moving on a map. Assume 2 million orders a day, most of them in a two-hour dinner window, and riders on flaky mobile networks.Chat and real timeOpen
- CodingMediumZomatoCompany listsMinimum Size Subarray SumGiven an array of positive integers and a positive target, return the length of the shortest contiguous run of elements whose sum is at least the target, or 0 if no run is big enough. For target 7 and [2,3,1,2,4,3] the answer is 2, from the run [4,3]. The array can hold 100,000 numbers, so checking every pair of ends is too slow.Sliding windowO(n) timeOpen
- System designZerodhaPrep guidesDesign live market data delivery to many clientsDesign a system that streams live price updates for about 5,000 traded instruments to 1 million connected users during market hours. Each user watches a list of up to 50 instruments, and a price change should reach the screen within a few hundred milliseconds.Streams and jobsOpen
- CodingMediumZerodhaCompany listsMaximum Subarray SumGiven an array of integers that may hold negatives and zeros, return the largest sum of any non-empty run of consecutive elements. For [-2,1,-3,4,-1,2,1,-5,4] the answer is 6, from the run 4,-1,2,1. The array holds up to 100,000 values, so adding up every possible run separately is too slow. This is a guide level question: a prep guide names it as its example array problem for Zerodha, and no candidate report of it was found.Kadane's running sumO(n) timeOpen
- CodingMediumZerodhaCompany listsValidate a Binary Search TreeA binary tree arrives in level-order form, with null marking a missing child. Decide whether it is a valid binary search tree: for every node, all values in its left subtree must be strictly smaller and all values in its right subtree strictly larger, so duplicates make a tree invalid. For [10,5,15,null,null,6,20] the answer is false, because 6 is a fine left child of 15 yet sits in the right subtree of 10 while being smaller than 10. The tree has up to 100,000 nodes and may be a long chain. This is a guide level question: a prep guide gives it as its tree example for Zerodha, and no candidate report of it was found.Tree walk with value boundsO(n) timeOpen
- CodingMediumZerodhaCompany listsRemove the Nth Node From the End of a Linked ListYou get a singly linked list, written here as an array from head to tail, and a number n. Delete the node that is n places from the tail, where n = 1 means the last node, and return the list that remains. For [1,2,3,4,5] and n = 2 the result is [1,2,3,5]. You may assume 1 <= n <= length, and the list can hold up to 100,000 nodes. The list does not store its length and cannot be walked backwards, so aim to do it in a single pass. This is a guide level question: prep guides list it among Zerodha linked-list topics, and no candidate report of it was found.Two pointers with a fixed gapO(L), L is the list length timeOpen
- CodingMediumZerodhaCompany lists0/1 KnapsackYou have items with given weights and values and a bag that can carry a total weight of at most capacity. Each item can be taken once or left behind. Return the largest total value you can carry. For weights [1,3,4,5], values [1,4,5,7] and capacity 7 the answer is 9, from the items of weight 3 and 4. There are up to 200 items, the capacity goes up to 10,000, and weights and values are non-negative integers. This is a guide level question: a prep guide gives it as its dynamic programming example for Zerodha, and no candidate report of it was found.Knapsack table over capacityO(n × capacity) timeOpen
- System designGrowwPrep guidesDesign an order pipeline that never loses or duplicates a tradeDesign the backend path of a stock-trading app from the moment a user taps buy to the confirmation. Assume 5 million orders a day with a heavy burst at market open, an external exchange link that can time out, and a rule that an order is never lost and never placed twice.Orders and moneyOpen
- Machine codingGrowwPrep guidesExpense sharing with debt simplificationDesign an expense-sharing app in the style of Splitwise, with users, groups and balances. People in a group add expenses that one person pays and several people share, and the app must always show who owes whom. Build it as an in-memory machine-coding task that is easy to extend with new ways of splitting.Wallets and paymentsOpen
- System designPaytmPrep guidesDesign an end-to-end UPI-style payment flowDesign the flow when a user pays another person from a mobile app using a payment address, with a central switch connecting the banks. Assume 10 million payments a day, a bank that sometimes answers slowly or not at all, and a rule that money is never debited twice or lost.Orders and moneySDE-2 and seniorOpen
- Machine codingPaytmPrep guidesDigital wallet with atomic transfersDesign a digital wallet in which users hold a balance, add money and send money to each other. Every movement has to keep the books correct: a transfer either happens in full or not at all, nothing is lost or created when a step fails halfway, and a repeated request must not move the money twice.Wallets and paymentsOpen