Project · Data Structures and Algorithms (DSA) for interviews
Project: an order desk for a cloud kitchen (JavaScript)
The brief
Build the order desk for a Hyderabad cloud kitchen in JavaScript: drop repeated orders, count dishes, queue orders for the kitchen, find the busiest stretch of minutes, warn how long until a busier minute, and merge two riders' delivery times. Every function is O(n) or close to it.
Why it matters
Food delivery and quick-commerce apps handle thousands of orders a minute. Their backend and dashboard code is exactly these patterns: a Set to drop retries, a Map to count, a queue for the kitchen, sliding windows for peak load and a monotonic stack for "next bigger" questions, which also come up often in JavaScript interviews.
Skills you practise
- Set and Map
- sorting with a comparator
- a queue without shift()
- fixed sliding window
- monotonic stack
- merging sorted arrays
What you will have at the end
desk.js: a tested order desk for a cloud kitchen, with the time and space cost of each function written in a comment above it.
How it is marked (rubric, 100 points)
| Correct resultsAll six steps pass, including empty input, ties and the 100,000-item checks. | 40 |
|---|---|
| Right complexitySet and Map for O(1) lookups, a head index instead of shift(), a sliding window and a monotonic stack: nothing O(n²). | 30 |
| Clean JavaScriptconst and let used well, clear names, no global variables changed by the functions. | 15 |
| ExplainedEach function has a one-line comment with its time and space complexity. | 15 |
0/6 steps done
Step 1 of 6
Drop repeated orders
uniqueOrders(orders) returns the orders with repeated ids removed, keeping the first copy and the original order.
The delivery app retries when the network is slow, so the same order id can arrive twice. A Set remembers which ids you have kept; has() and add() are O(1) on average.
One pass is O(n) time and O(n) space. Checking each order against the result array with includes() or some() would be O(n²).
Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.