Kotak Bank Interview Experience
Summary
I had an interview experience with Kotak Bank, which included a Bar Raiser round with a coding question, a Low-Level Design problem, and several Distributed Architecture questions.
Full Experience
Round 1: Bar Raiser round
Coding Question:
Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.
Input: matrix = [[1,1,1],[1,0,1],[1,1,1]] Output: [[1,0,1],[0,0,0],[1,0,1]]
Input: matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]
Output: [[0,0,0,0],[0,4,5,0],[0,3,1,0]]
Constraints:
m == matrix.length n == matrix[0].length 1 <= m, n <= 200 -2^31 <= matrix[i][j] <= 2^31 - 1
class Solution {
public int[][] solve(int[][] input) {
int m = input.length;
int n = input[0].length;
// boolean[] rows = new boolean[m];
// boolean[] cols = new boolean[n];
boolean firstRow = false;
boolean firstCol = false;
for(int i = 0; i < m; i++) {
for(int j = 0; j < n; j++) {
if (input[i][j] == 0) {
if(i == 0) {
firstRow = true;
}
if (j == 0) {
firstCol = true;
}
input[i][0] = 0;
input[0][j] = 0;
}
}
}
for(int i = 1; i < m; i++) {
for(int j = 1; j < n; j++) {
if (input[i][0] == 0 || input[0][j] == 0) {
input[i][j] = 0;
}
}
}
if(firstRow) {
for(int j = 0; j < n; j++) {
input[0][j] = 0;
}
}
if (firstCol) {
for(int i = 0; i < m; i++) {
input[i][0] = 0;
}
}
return input;
}
}
class Main {
public static void main(String[] args) {
// int[][] input = {
// {1,1,1},
// {1,0,1},
// {1,1,1}
// };
int[][] input = {
{1,0,0},
{2,3,4},
{5,6,7}
};
/*
[
[1, 0, 0],
[2, 3, 4],
[5, 6, 7]
]
[
[1, 2, 0],
[3, 4, 0],
[5, 6, 7]
]
[
[1, 2, 3, 4],
[5, 0, 7, 8],
[0,10,11,12],
[13,14,15,0]
]
*/
// int[][] input = {
// {0,1,2,0},
// {3,4,5,2},
// {1,3,1,5}
// };
Solution solution = new Solution();
input = solution.solve(input);
for(int i = 0; i < input.length; i++) {
for (int j = 0; j < input[i].length; j++) {
System.out.print(input[i][j] + " ");
}
System.out.println();
}
}
}
LLD
Online Marketplace - Buy & Sell Products
Prompt: Design the backend components for an online marketplace where users can buy and sell products. Consider features such as user authentication, product listing, search functionality, shopping cart, and order management.
🔸 Sub-components to explore: User Authentication – Signup, Login, JWT-based session Product Listing – Sellers can create, update, delete, and view listings Search Functionality – Full-text search and filtering Shopping Cart – CRUD operations on items Order Management – Placing, viewing, and cancelling orders
Distributed Architecture Questions:
- Explain how you would ensure data consistency across multiple nodes in a distributed database.
- Discuss the challenges and techniques for handling distributed session management.
- Explain the role of distributed messaging systems like Kafka or RabbitMQ in a backend system.
Interview Questions (5)
Set Matrix Zeroes
Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.
Input: matrix = [[1,1,1],[1,0,1],[1,1,1]] Output: [[1,0,1],[0,0,0],[1,0,1]]
Input: matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]
Output: [[0,0,0,0],[0,4,5,0],[0,3,1,0]]
Constraints:
m == matrix.length n == matrix[0].length 1 <= m, n <= 200 -2^31 <= matrix[i][j] <= 2^31 - 1
Low-Level Design: Online Marketplace
Prompt: Design the backend components for an online marketplace where users can buy and sell products. Consider features such as user authentication, product listing, search functionality, shopping cart, and order management.
🔸 Sub-components to explore: User Authentication – Signup, Login, JWT-based session Product Listing – Sellers can create, update, delete, and view listings Search Functionality – Full-text search and filtering Shopping Cart – CRUD operations on items Order Management – Placing, viewing, and cancelling orders
Distributed Database Data Consistency
Explain how you would ensure data consistency across multiple nodes in a distributed database.
Distributed Session Management Challenges
Discuss the challenges and techniques for handling distributed session management.
Role of Distributed Messaging Systems
Explain the role of distributed messaging systems like Kafka or RabbitMQ in a backend system.