Flipkart Machine coding round for SDE-2

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-06-22Added By Anonymous
Source: Link

Company: Flipkart
Role: SDE-2
Interview Stage: Machine Coding
Location: unknown
Year: unknown

Original Post Content:

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:

  • Onboard new restaurants with menu and processing capacity.
  • Update restaurant menu/prices dynamically.
  • Place orders based on a restaurant selection strategy.
  • Orders must only be accepted if all items are available and capacity allows.
  • Dispatch orders, making room for new ones.
  • Keep track of items served per restaurant.
  • Process a set of commands sorted by timestamp (even if given in random order).
  • [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 Interviewer 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