Round 1: Machine Coding/LLD

(90 mins: 30 mins problem statement discussion +1 hr for coding)

In this round, the Question was to design a vehicle rental service such as Zoomcar. The functional requirements were like these:

Features:

  1. Rental services have multiple branches throughout the city. Assume one city for now.
  2. Each branch has a limited number of different types of vehicles.
  3. Each vehicle can be booked with a predefined price. For simplicity, assume fixed pricing.
  4. Each vehicle can be booked in multiple 1-hour slots. a. For simplicity, assume slots of a single day. b. For simplicity: assume slots to be from 00-59 i.e.: 9 am-10 am, 10 am-11 am, 11 am-12 noon and so on 5. No past bookings should be allowed.

Requirements:

  1. Onboard a new branch with an available vehicle
  2. Onboard new vehicle(s) of existing type to a particular branch
  3. Rent a vehicle for a time slot and a vehicle type(lowest price as the default choice extendable to any other strategy).
  4. 4. Display available vehicles for a given branch

Also, you can’t use any database here and have to use in-memory data structures for all operations which makes the CRUD operations a bit more annoying and this would be a CLI-driven system.

You have only 1 hour to complete these. But there is no need to panic here. Remember functionality is king, so make sure to get proper coverage of your requirements before thinking about design patterns. To ensure that your code is modular, extensible and follows good design principles you can use any language that provides proper project structure, boilerplate code and build tools to make your life easier. Due to familiarity, I used Gradle and Java 17.

Also make sure your driver code is ready to demo the functionality you built, so be sure to give it a few dry runs beforehand.

Just from a high level, this is how I proceeded:

Analyzed the requirements and identified the entities Created the Model/POJO and DTOs classes for these entities. It is not necessary to create complete models at the first attempt. You can always add/remove stuff later.

So start with some basic fields first Identify the interaction points of the user along with the system and create services and controllers respectively. It is also a good idea to make these loosely coupled and perform dependency injection which is otherwise handled by frameworks such as Spring.

You could also create repositories but since all CRUD operations are memory-based, I decided to not create one.- Created exception classes including a Global Exception handler and a minimal exception hierarchy which includes client-based, server-based exception classes(Optional and should be on low priority)

In service methods, I used Collections and Stream API extensively to satisfy all functional requirements. Recommend to split code in multiple lines as readability can be compromised by excessive chaining in streams. Since the database state would be persisted in these collections I made them thread-safe (completely optional).

With all that being said, it is completely ok if you are unaware of how to do some of these steps given that you create a working system. Remember this Design principle- KISS?

Knowledge of DSA can easily help you to simplify your CRUD operations. For example, Requirement 3 sounds complex to implement but you can do it easily if you use a min Heap and take an Overhead on insert_vehicle queries because insert_vehicle queries will be less often than book_behicle queries. Hence the complexity of book_vehicle is greatly reduced. For Requirement 4, I had to simply override the toString method of Java Object. For entities such as Slots, you need to design this data structure by wrapping around some objects which would both maintain the state info for display as well as be comparable with each other. Again, if you are unable to create these data structures, you should make acceptable assumptions and move on.

In the end, I refactored some code to make it readable and used dependency Inversion to make the code extensible.

After I designed this, I had an evaluation round with a panel of SDE2s at Flipkart, where certain use cases were tested. Make sure you have already written most of the driver code. The interviewer gave me certain use cases to run the system against and satisfied almost 99% of them. Then followed up with questions on design patterns which I had used a few in my system.

  • Factory- Use for Generating Vehicles of different Make
  • Strategy- For pricing requirements use the price Calculator strategy
  • Singleton- For managing thread-safe instances of controller, services etc

Also received Questions on the schema design and how would I handle certain relationships in my schema and some database storage and Query pattern-related questions

Flipkart Interview Experience For SDE-2 (Off-Campus)

The interview rounds kick-started around 1st week of March 2024 and the details are as below:

Similar Reads

Round 1: Machine Coding/LLD

(90 mins: 30 mins problem statement discussion +1 hr for coding)...

Round 2: DSA/PSDS

(1 hr for solution discussion, optimization and coding)...

Round 3: Design(LLD+HLD)-60 mins

In this round, I was interviewed by some SDE3s at Flipkart...

Round 4 : Techno-Managerial Round(60 mins)

In this round, I was interviewed by a Senior EM at Flipkart, where we discussed my profile and experience....

Round 5: HM Connect

This was just a normal connection with the hiring manager discussing the technical ecosystem, the LOBs, team structure, culture fitment and understanding of the role. I had a few follow-up questions and the manager was very well-spoken and responded very clearly. It was great to get some insights into the organization and understand the scale at which tech operates there. Also talked about individual progression, benefits and most importantly the Engineering culture....

Contact Us