Flipkart Machine coding round for SDE-2

Anonymous User
1561
Jun 22, 2025
Jun 22, 2025

Problem Statement

Last month, I appeared for a machine coding round at Flipkart, where I had to implement a simplified food order management system, named FoodKart. It was a 120-minute round, with 30 minutes for problem briefing and 90 minutes for implementation.

The problem involved designing a system that simulates food ordering from restaurants with in-memory data structures. The challenge tested object-oriented design, modularity, clean coding, and extensibility. No UI or database, just plain backend logic.

Key Features to Implement:

  1. Onboard new restaurants with menu and processing capacity.

  2. Update restaurant menu/prices dynamically.

  3. Place orders based on a restaurant selection strategy.

  4. Orders must only be accepted if all items are available and capacity allows.

  5. Dispatch orders, making room for new ones.

  6. Keep track of items served per restaurant.

  7. Process a set of commands sorted by timestamp (even if given in random order).

  8. [Bonus] Show all dispatched orders.

My Design Approach:

I applied solid OOP principles and followed modular design using the following key classes:

Restaurant – encapsulates name, menu, and current processing capacity.

MenuItem – represents an item with its price.

Order – stores order ID, items, status, and selected restaurant.

RestaurantSelectorStrategy – an interface to allow plug-and-play selection strategies (e.g., LowestTotalPriceSelector).

FoodKartService – the service layer orchestrating all business logic.

CommandProcessor – parses and executes timestamped commands in order.

Restaurant Selection Strategy:

Implemented a simple strategy:
👉 LowestTotalPriceSelector – selects the restaurant that offers the lowest total cost for all ordered items.

This was made extensible using a Strategy Pattern, so adding new logic (like fastest dispatch time, rating, etc.) would be easy.

Input/Output Handling:

Took commands as strings with timestamps.

Parsed and sorted based on timestamps before processing.

Used STDOUT for all outputs like:

Menu after updates

Order status and assigned restaurant

Dispatch confirmations

5, place-order, order2, item1, item2, item3
2, update-price, restaurant3, item1, 50
8, dispatch-order, order2
5, place-order, order3, item2, item3
3, place-order, order1, item1

Evaluation Round

After two days I got a call for evaluation round, where Interviwer asked me to run my code to make sure my code is passing for all test cases.

** If you’re preparing for product-based company interviews, especially for machine coding rounds, I highly recommend practicing such problem statements where both design and code quality are evaluated.**

#Flipkart #SystemDesign #MachineCoding #InterviewExperience

Comments (3)