Most Popular Machine Coding Interview Questions That You Should Practice

Here is a list of most popular machine coding interview questions that you should prepare for your upcoming machine coding round.

The interview process for startups has changed a lot in recent times. Previously, companies used to look for candidates who are smart and can be groomed by senior members in the teams. Because of this expectation, companies used to rely a lot on Data Structures based questions. I can recall, a few years back all companies had at least 3 interview rounds which were based purely on data structures followed by HR round and Hiring Manager round.

But, now the requirements of companies have changes a lot. These days they are not planning to spend a lot of time on grooming people. They want people who can join and start contributing with minimal guidance. Since the expectations from candidates has changed, therefore the interview process has changed a lot as well.

These days the general process of interviews for companies is like this - Data Structures round, Low Level Design Round, Machine Coding Round, High Level Design Round (SDE 2 and above), Hiring Manager Round and finally HR Round.

As you can see from the interview process above, companies want people who have a knack for code designing and want to hire people who can write functional code from day 1. This is where Machine Coding rounds come into play. The expectation from candidate is to write fully functional code using best object oriented design practices. You are also expected to use SOLID programming principles while building this application.

Read more about SOLID Programming Principles here.

In this article we will discuss some of the most popular interview questions that you can expect in a machine coding round. You can practice these questions and keep yourself prepared before your upcoming machine coding interview round.

Design Parking Lot System

You need to create a Parking Lot Management System as a simple command line based application. This application should provide the following functionalities.

  1. Park a vehicle in the first available parking spot.
  2. Remove a vehicle from a parking spot once the owner is back.
  3. Generate parking ticket when vehcile gets parked, and generate bill when the vehicle gets removed.
  4. Ability to add more floors to the parking lot.
  5. Ability to add more parking spots to the parking floor.
  6. Get vehicles by number plate from a parking lot.

The requirements from a parking lot system can be huge, hence you need to design your system in the most plug and play mode possible.

You can refer to our article on How to design parking lot system in Java for more details.

Design Splitwise

If you don't know, let me give a you a crash course on what splitwise is. Splitwise is an application where you can split expenses between family and friends. You can also create groups and add expenses in them so that all the expenses are in at a common place. You can choose to split the expense equally or based on percentage or in absolute terms like A needs to 200 and B needs to pay 250.

An application like this should have the following functionalities:

  1. Split expense between multiple people.
  2. Expense can be split either based on percentage, equally or in absolute terms.
  3. Show money owned to a specific person. Example A, B and C owe Rs 100 to D.
  4. Show money onwed by a specific person. Example A owes Rs 100 to D and Rs 500 to C.
  5. Show balances of all the people in the system. Who owes whom what amount.
  6. Ability to create groups and add expenses in them.

Design Snakes and Ladder

Snakes and Ladder is one of the oldest games in that I personally have played. It contains a basic board with Snakes (they bring you back to lower cells) and Ladders (they take you to higher cells). Each player takes turn and roll dice, and based on the number appearing on the dice, they move that many steps.

Below are the requirements from a Snakes and Ladder game:

  1. Ability to define Snakes and Ladders on the board by using two positions. First one defines the starting point and second one defines ending point. Example: Snake (99, 48) defines a snake that bring back a player from cell 99 to cell 48.
  2. Define number of players in the game.
  3. Each player plays one by one. First person to reach 100 wins.

Design a distributed queue like Kafka

This is one of my favourite interview questions to be asked in Machine Coding interviews. The reason why this is my favourite is because this question helps in testing a candidates coding skills, plus ability to make systems resilient and fault tolerant.

Below are the requirements for this question:

  1. Completely in-memory implementation of this queue.
  2. There can be multiple topics in the system.
  3. Multiple publishers can publish into single topic.
  4. Multiple consumers can read from a topic.
  5. There should be mechanism to acknoledge messages.

These are some of the most popular interview questions that are asked in Machine Coding Rounds. We will keep on updating this list with more articles.