Summary
I recently interviewed for the SDE 3 role at Kotak, where I was presented with a detailed system design problem to implement a Battleship game, ultimately resulting in a rejection.
Full Experience
During my BarRaiser round at Kotak for the SDE 3 position, I was given a system design challenge: to design and implement a two-player Battleship game. The problem came with extensive requirements, including a square battlefield, ship placement and size inputs, and a random coordinate firing strategy. I had to implement mandatory APIs such as initGame, addShip, and startGame, and there was an optional viewBattleField API. The evaluation focused on code functionality, readability, separation of concerns, abstraction, OOP concepts, language proficiency, and scalability. Despite my efforts in designing the system and implementing the required functionalities, I was unfortunately rejected for the role.
Interview Questions (1)
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.
The following APIs have to be implemented:
Mandatory:
initGame(N)
This will initialize the game with a battlefield of size NxN. Where the left half of N/2xN will be assigned to PlayerA and the right half will be assigned to PlayerBaddShip(id, size, x position PlayerA, y position PlayerA, x position PlayerB, y position PlayerB)
This will add a ship of given size at the given coordinates in both the player’s fleet.startGame()
This will begin the game, where PlayerA will always take the first turn. The output of each step should be printed clearly in the console.
For eg.PlayerA’s turn: Missile fired at (2, 4).
“Hit” . PlayerB’s ship with id “SH1” destroyed.
PlayerB’s turn: Missile fired at (6, 1).
“Miss”
Optional:
viewBattleField()
This will display the battlefield as a NxN grid and all the ships along with the grids occupied by each ship. PlayerA’s ship with id SH1 will be marked as A-SH1, with id SH2 as A-SH2 and so on. Whereas PlayerB’s ships will be marked as B-SH1, B-SH2 and so on.
Note: It should mark all the grids occupied by a ship and not just the center coordinate.
Guidelines:
- You should store the data in-memory using a language-specific data-structure.
- You can print the output in the console.
- Design your application in a way that a new fire strategy can be implemented and used instead of the default one (random coordinate).
- Implement clear separation between your data layers and service layers.
Expectations:
- Your code should cover all the mandatory functionalities explained above.
- Your code should be executable and clean.
- Your code should be properly refactored, and exceptions should be gracefully handled.
- Appropriate errors should be displayed on console when user input violates the rules of the game.
How will you be evaluated?
- Code Should be working
- Code readability and testability
- Separation Of Concerns
- Abstraction
- Object-Oriented concepts.
- Language proficiency.
- Scalability
- Test Coverage (Bonus Points)
Sample Execution:
>> initGame(6)
>> addShip(“SH1”, size = 2, 1, 5, 4, 4)
>> viewBattleField()
>> viewBattleField()Summary
I recently interviewed with Kotak Mahindra for an SDE 2 role, which spanned three rounds covering Data Structures & Algorithms, general distributed systems concepts, and a Low-Level Design problem.
Full Experience
My interview journey with Kotak Mahindra for an SDE 2 position was structured across three distinct rounds.
The first round, a Barraiser round, tested my foundational knowledge. I was presented with standard DSA problems like Two Sum, Search in Rotated Sorted Array, and Set Matrix Zeroes. Beyond coding, we also delved into general concepts related to distributed systems, which required a broader understanding of architectural principles.
The second round was purely focused on Data Structures and Algorithms. This round was quite challenging, featuring problems such as First Missing Positive, which I found particularly tough to solve, Burst Balloons, and Longest Increasing Path in a Matrix. This round truly pushed my problem-solving abilities.
Finally, the third round was a Low-Level Design (LLD) challenge. I was tasked with designing a Hospital Management System. The key requirements included patient registration with priority assignment, a priority queue for patients, an initial consultation process by a doctor, subsequent assignment to specialist doctors, and maintaining comprehensive treatment records. This round assessed my ability to translate abstract requirements into a robust system design.
Interview Questions (7)
There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed). For example, [0,1,2,4,5,6,7] might be rotated at pivot index 3 and become [4,5,6,7,0,1,2]. Given the array nums after the possible rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.
You are given n balloons, indexed from 0 to n - 1. Each balloon is painted with a number on it represented by nums[i]. You are asked to burst all the balloons. If you burst the i-th balloon, you will get nums[left] * nums[i] * nums[right] coins. left and right are adjacent indices of i. After the burst, the left and right then become adjacent. Find the maximum coins you can collect by bursting the balloons wisely.
Design a Hospital Management System. Requirements:
- Patients are first registered at Reception, who assigns them a priority level (Critical, High, Medium, Low).
- Patients wait in a priority queue.
- An Initial Consultation Doctor picks the next patient from the queue.
- After consultation, patient is assigned to a Specialist Doctor.
- System should maintain treatment records.
Summary
I recently had a screening round for Kotak that included a coding problem and system design questions. Unfortunately, I was rejected as my LLD skills were not up to par, and I was quite rusty after a long break from interviewing.
Full Experience
I recently had the opportunity to appear for a screening round with Kotak, organized by a bar raiser. The interview lasted 1 hour and 30 minutes and consisted of three main parts: a coding problem, a system design problem, and a discussion on high-level design concepts. I realized I hadn't brushed up on Low-Level Design (LLD) in a long time, and my performance reflected that. This was also my first interview in about a year, so I was a bit rusty.
Interview Questions (3)
Given a sorted array that has been rotated at some pivot, find a target element within it efficiently.
Design a comprehensive system to manage inventory. This includes functionalities like adding new products, updating stock levels, tracking sales, handling returns, and generating reports.
The interviewer posed high-level design questions, specifically asking how one would ensure data consistency in a distributed system when some of its nodes fail.
Preparation Tips
I hadn't brushed up on Low-Level Design (LLD) for a long time, which negatively impacted my performance. I was also quite rusty, as I hadn't given an interview in about a year.