Warehouse Order Prioritization
Updated
Problem statement
A delivery company packs orders in its warehouses before dashers (its delivery drivers) pick them up. Given the ID warehouseId of one warehouse, choose the two orders of that warehouse that should be packed first: the ones whose dashers are expected to arrive soonest.
In a real system this data would come from two other services. Here their replies are passed in as arrays:
ordersis the reply of the order service. Each row[orderId, warehouse]is one order and the warehouse it belongs to. The orders of the requested warehouse are the rows whose second value is exactly equal towarehouseId.etaRepliesholds the reply of the ETA service for every order inorders, in any order. Each row[orderId, eta]gives the dasher's expected arrival time in minutes as a decimal string, or the string"FAILED"if the lookup for that order did not succeed.
Rank the orders of the requested warehouse. An order with a known ETA goes before every order whose lookup failed; a failed order is still ranked, just behind all known ETAs. Known ETAs are compared as numbers, smaller first. When two orders have the same ETA, or both lookups failed, the one that appears earlier in orders goes first.
Return the IDs of the first two orders in this ranking, best first. If the warehouse has only one order, return just that ID; if it has no orders, return an empty list.
Function
prioritizeOrders(warehouseId: String, orders: String[][], etaReplies: String[][]) → String[]Examples
Example 1
warehouseId = "W2"orders = [["A1","W2"],["A2","W1"],["A3","W2"],["A4","W2"],["A5","W2"]]etaReplies = [["A3","9"],["A1","25"],["A5","FAILED"],["A2","3"],["A4","12"]]return = ["A3","A4"]Warehouse W2 has orders A1, A3, A4 and A5; A2 belongs to W1, so its ETA of 3 does not count. The known ETAs are 25 for A1, 9 for A3 and 12 for A4, and the lookup for A5 failed. The two smallest ETAs are 9 and 12, so the answer is ["A3","A4"].
Example 2
warehouseId = "SEA-1"orders = [["B4","SEA-1"],["B8","SEA-1"],["B1","SEA-1"]]etaReplies = [["B1","FAILED"],["B8","30"],["B4","FAILED"]]return = ["B8","B4"]Only B8 has a known ETA, so it comes first. The lookups for B4 and B1 both failed; they are tied, and B4 is listed before B1 in orders, so B4 is second.
Example 3
warehouseId = "W5"orders = [["X3","W5"],["X1","W5"],["X2","W5"]]etaReplies = [["X1","7"],["X2","4"],["X3","7"]]return = ["X2","X3"]X2 has the smallest ETA, 4. X3 and X1 share ETA 7; X3 comes earlier in orders, so it takes the second place.
Constraints
1 <= warehouseId.length <= 120 <= orders.length <= 1000orders[i].length == 2etaReplies.length == orders.lengthandetaReplies[i].length == 2- Every warehouse ID and order ID has 1 to 12 characters, each an uppercase letter, a digit or
-. - The order IDs in
ordersare distinct, andetaReplieshas exactly one row for each of them. - Every ETA is either
"FAILED"or a whole number from0to10000written without leading zeros.
More DoorDash Phone Screen questions
- Dasher Pay with Store Waits and Peak HoursPHONE SCREEN · Seen Nov 2026
- Customer Bootstrap APIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Dasher Active TimePHONE SCREEN · Seen Sep 2026
- Merchant Capacity Interval MergePHONE SCREEN · Seen Aug 2026
- Open Restaurants in a City RangePHONE SCREEN · Seen Aug 2026
- Closest DashMartOA · PHONE SCREEN · Seen Jul 2026
- Maximize Total Profit by Assigning Chefs to DishesPHONE SCREEN · Seen May 2026
- Minimum Batches Within a Time WindowPHONE SCREEN · Seen Feb 2026
- Minimum Riders for Delivery IntervalsPHONE SCREEN · Seen Feb 2026
- Return Priority of Order IDsPHONE SCREEN · Seen Jun 2025
Similar questions at other companies
- Merge Accounts by Shared AttributeAmazon · PHONE SCREEN
- Mutual-Friend Referral RecommendationsFireworks AI · PHONE SCREEN · ONSITE INTERVIEW
- Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- Log Analyzer: Busiest Service in a Rolling WindowByteDance · PHONE SCREENByteDance interview questions
- User Journey PathsWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
- Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesStripe · PHONE SCREENStripe interview questions
- Longest Consecutive SequenceJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
- Top K Frequent Elements with a Recency TiebreakSwiggy · PHONE SCREEN
DoorDash interview experiences
- DoorDash SWE Onsite: Donation System Design: 1 Experience
- DoorDash SWE Phone Screen: Bootstrap API in Java: 1 Experience
- DoorDash SWE Virtual Onsite: 1 Experience
- DoorDash SWE Phone Screen: Bootstrap API Parsing: 1 Experience
- DoorDash Senior SWE Onsite Interview Experience: 1 Experience
- DoorDash AI CodeCraft Interview: 8 Experiences