Kotak Mahindra | Machine Coding | SDE2/3 | Backend Developer | With Solution

kotak mahindra bank logo
kotak mahindra bank
· SDE2/3 Backend Developer
February 8, 2026 · 11 reads

Summary

I participated in a machine coding interview round for a SDE2/3 Backend Developer role at Kotak Mahindra, where I was challenged to design and implement a Battleship game.

Full Experience

The interview involved a single machine coding problem where I had to build a complete Battleship game system based on detailed specifications, and then provide a working solution.

Interview Questions (1)

1.

Battleship Game Design & Implementation

System Design·Hard

Question: BattleShip Game

Design and implement a battleship game to be played between two players until one comes out as the winner.

Requirements:

  • The game will be played in a square area of the sea with NxN grids which will be called a battlefield. “N” should be taken as input in your code.
  • The battlefield will be divided in half between both the players. So in a NxN battlefield, NxN/2 grids will belong to PlayerA and the other NxN/2 grids will belong to playerB
  • The size and location of each ship will be taken as input. Each ship will be assumed to be of Square shape. Both the players should be assigned equal fleet.
  • The location of each ship in the NxN grids has to be taken as input (X, Y). X and Y should be integers. For eg. if a ship “SH1” is at (2, 2) and has the size of 4, its corners will be at (0, 0), (0, 4), (4, 0) and (4,4)
  • Ships will remain stationary. No two ships should overlap with each other. However they can touch boundaries with each other.
  • Each player will fire one missile towards the enemy field during his turn using the “random coordinate fire” strategy, which means the missile will hit at a random coordinate of the opponent’s field. It might hit or miss the opponent ship. In either case the turn is then transferred to the other player.
    • In case of a hit, the opponent’s ship is destroyed.
    • In case of a miss, nothing happens.
  • No two missiles should ever be fired at the same coordinates throughout the course of the game.
  • When all the ships of a particular player has been destroyed, he loses the game.
Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!