In recent days, a new type of interview round has been introduced in the software world known as Machine Coding Round. Candidates are usually not aware of this round or what they will be asked in this round and end up getting rejected because of it. This is why we will be covering machine coding round in detail so that you are well prepared and ready to take the challenge head-on.
It is one of the interview rounds in Flipkart. But Flipkart isn’t the only company that has a Machine Coding Round. A lot of other companies have also introduced this round in their interview structure. Some of the companies that have added machine coding rounds in their interview structure are:
- Supr Daily
- WhiteHat Jr
Now that we know these companies have a machine coding round, it’s better to learn what it is and what should be done to clear this round.
What is Machine Coding round?
In machine coding rounds, you will have to design the entire system in approximately 2-3 hours. You will be given a question at the start of the interview, and you need to write fully functional code that fulfills all the requirements mentioned by the interviewer. In the end, you need to tell the interviewer about your design in detail. After this, the code will need to be run against some inputs provided by the interviewer. And if there are some issues in your code, the interviewer will point those out and you need to take care of the issues.
The code that you write is judged on the basis of certain criteria. And almost all companies have the same criteria when it comes to machine coding. But make sure you are flexible enough to adapt to the situation. And if the interviewer changes or adds some condition, act according to it.
In a machine coding round, you don’t need to take care of a database connection or even store the data in a database. Just create an in-memory database. You can use a HashMap for this purpose.
In the case of Flipkart, it is a part of the interview structure for SDE-1 and SDE-2 roles. But it might be asked for SDE-3 roles too depending on the situation. And the general duration for Machine Coding Round in Flipkart is around 2 hours.
Machine Coding round sample/ practice questions
There are a lot of examples/ questions for machine coding rounds. Following are some of the example questions. The companies in which they have been asked are in brackets.
- Digital Wallet System (Flipkart)
- Concurrent In-memory Publisher-Subscriber System (Uber)
- Ride-Sharing Application (Flipkart)
- Coffee Machine (Flipkart)
- Splitwise (Swiggy, Flipkart, Upstox)
- In-memory Task Scheduler Library (Uber)
- Snakes & Ladders
- Conference Room Management System (Flipkart)
- Online Coding Platform (Flipkart)
- Movie Booking System
- Parking Lot Design (Swiggy)
- Library Management System
As of now, I have included the solution for one question Digital Wallet Design – Machine Coding Round Solution. Do look at the solution for this question and practice on your own. Only if you practice on your own will you be able to improve your skills. If you want me to cover more questions and their solutions, please leave a comment.
Machine Coding round expectations
- The code/ application should be executable. This is the most important expectation in a machine coding round.
- The code should fulfill all the requirements mentioned by the interviewer.
- The system/ code should be modular and easy to understand.
- Your code should follow object-oriented principles.
- Use a design pattern if possible.
- The code should be easily extensible, which means it should be designed to allow the addition of new capabilities or functionality.
- Don’t dump all the code in one class. You should have different classes for different purposes. Follow the single responsibility principle.
- You will need to write a driver method or a driver class which will drive the entire flow. A class that has the main method and from where methods of other classes are called is known as a driver class.
- You should be able to explain what you have written to the interviewer in a simple and concise manner.
How to Prepare for Machine Coding round
Now that we know what the company/ interviewer expects from us, we must move on to how to prepare for his round.
Learn about Design Patterns
A good start to preparations is to learn about design patterns. Design patterns are sample or general solutions to commonly occurring problems in the software world. And there are a lot of scenarios where design patterns are useful. One of the scenarios where it fits well is the machine coding round. Suppose you have a scenario where you need a single object for a particular class. You can use the Singleton design pattern here. Similarly, think of other scenarios where design patterns can be used.
Learn about SOLID principles
SOLID is an acronym for the first five object-oriented design principles. These principles help in writing code that is easy to read and also maintain. The terms SOLID stands for:
- S – Single Responsibility Principle – Every class should have only responsibility.
- O – Open-closed Principle – Entities should be open for extension but closed for modification.
- L – Liskov Substitution Principle – Every subclass must be substitutable for its parent class.
- I – Interface Segregation Principle – Client shouldn’t be forced to implement an interface it doesn’t use.
- D – Dependency Inversion Principle – Entities must depend on abstractions, not concretions.
Learn to write Object-Oriented Code
When writing code for production or writing code in an interview, it is best to write object-oriented code. Create multiple classes where each class has different functionality and use. And don’t dump all the code in one file. Why? Because it becomes difficult to manage and read as well.
Practice Low Level Design(LLD)
If you have a good grasp of LLD, it makes cracking the machine coding round a bit easier. Why? Because low-level design is an integral part of machine coding. In low-level design, you define the classes, the interfaces, and the relationships between all these entities. Machine coding is taking it a step further, which makes it a natural extension of LLD.
Practice Machine Coding
Machine coding is a pretty difficult round as you are expected to write end-to-end code and it should be entirely functional. The main mantra to crack any interview in the world is to practice. And practice a lot. Before appearing for interviews, you should practice at least 2 to 3 machine coding problems so that you can get the gist of what is expected out of you. And remember, you should complete the code within the required timeframe. There’s no point in having fancy code if the project is not running.
Also check: Best Coding Platform To Become A Coding Expert
How to crack the Machine Coding round
We now know what to do to prepare for the machine coding round. But preparing for the interview is one thing, and giving the interview is a different thing altogether. We have to keep some things in mind during the interview.
We have covered how to crack machine coding rounds in step-by-step detail. They are as follows:
- Understand the problem statement clearly. And make sure the requirements are crystal clear to you.
- Don’t be afraid to ask questions to the interviewer if anything is not clear to you. And remember there are no silly questions.
- Don’t jump directly to implementation. Always take some time to think about what approach you will be taking (5-8 minutes).
- Start designing classes, make sure your design is confirming to OOPS concepts.
- Use design patterns if possible. As some companies look for these explicitly.
- Tell the interviewer about the implementation and approach you have chosen. And they might point out some mistakes or give some suggestions.
- Do proper estimation of how much time you require to code, how much time you require to test, and how much time you require to discuss and make changes.
- Once you are done with explaining the initial approach, open any IDE and start writing the classes, interfaces, and its members.
- Package your classes into different modules. For example, utility class should be under the utility package.
- Mark important fields as private and use getters and setters.
- Have a separate class as a driver class. And this class should contain the main method from where the entire application will be run.
- You must complete your coding 30 to 45 minutes before the scheduled time. So that you have time to discuss and make changes if necessary.
- During review, tell the interviewer about the important classes and the relationship between them.
- Tell them about SOLID principles if you have followed any. Also, inform about any design pattern you have used.
- The interviewer might ask you to run the code against some other input. And these will most likely be inputs to test your code limitations.
- It’s possible your implementation might not work for all the test cases. Don’t panic. Just think over what you could do different to handle that test case.
- Make corrections if necessary. Depending on how much time you have, you can make some minor or major modifications in your implementation.
Always be calm and confident. You are able to think clearly that way.
Good luck with your interviews folks!!!
Do leave a comment below or email me at email@example.com if you have any questions.
To keep yourself up to date with our latest content, please subscribe to our newsletter by dropping your email address here: Signup for Our Newsletter.
Please follow us on Medium.
- Digital Wallet Design – Machine Coding Round Solution
- How to crack technical interview – Google, Amazon & more
- How to Prepare for and Crack the Coding Interview
- Best Coding Platform To Become A Coding Expert
- Backtracking Algorithm Explained With Examples
- The ultimate guide to interview preparation