Analyze food-delivery data
CoinbaseSoftware Engineer · OnsiteLast updated
This interview question evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer for Analyze food-delivery data states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Question
You are given data for a food-delivery platform: a set of restaurants (each with a menu of items and prices, plus a geographic location) and a stream of orders (each referencing a restaurant, a set of menu items, an order total, and a timestamp). Implement the following:
-
Cheapest and nearest restaurant. Given a desired order (a set of menu items) and the user's location, return the restaurant that can fulfill the order at the lowest total price, and the restaurant that is geographically closest to the user.
-
Time-window order statistics. Given the menu item prices and a list of orders, compute over a given time window the total order price, the order count, and the average order value.
-
Top-K over the window. Over the same time window, return (a) the Top-K orders ranked by total price, and (b) the Top-K menu items ranked by sales/transaction volume.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.