There were total 2 telephonic rounds and 4 onsite rounds.
Given an array of Length N. You have to select two non overlapping K length subarrays from the given array such that the sum of elements of selected subarrays is maximum.
Given that 2*K <= N.
arr : 5 3 7 9 10 3 1 7 9 9 9 and k = 3
Here 2 subarrays will be 7, 9, 10 and 9, 9, 9
Given an array of integers and a integer k, find number of subarrays for which median is >= k. If numbers of elements in arrays is even then median it median will be number which is present in index
array_size/2 - 1.
input arr : [3, 6, 4, 5] and k = 4
Following are the subarrays with median >= k
[3 6 4]
[6, 4, 5 ]
[3, 6, 4, 5]
so here answer is 8.
Book my show Low level Design.
Here we first discussed about the main entities and class, ticket booking flow. Then interviewer asked me write the code for locking seats with some expiry.
In a tennis game player has to win S sets and to win each set he/she has to win T serves.
Given a list of serves win for a game, you have to find all possible combinations of T and S such that the input string is valid and there is a clear winner at the end of the string.
A denotes that player A wins the serve.
B denotes that player B wins the serve.
ABABA will have 2 combinations of T and S :
T=1, S = 3 : Here as T = 1 so first player who wins the serve will win one set. and as S = 3 so first player who wins 3 sets will win the game. So in this case A wins the game.
T = 3, S = 1 In this case A wins the set and hence wins the game as S = 1.
No other valid combinations of T and S are possible so answer is 2 in this case.
Design chat messenger app such that if the message of user A has reached server then it should get first delivered to user B and then only user B can send his message.
We discussed regarding message flow and building the constraint on the client side or server-side.
In this round we mainly discussed regarding my work and challenges in my project. We discussed some designs problem related to kafka.
Then interviewer asked me to build advertisement logic where we have N ads and k slots (k<N) and target is to make maximum profit.