# Directi SDE-2 Interview Experience

• Last Updated : 19 Aug, 2019

There were total 2 telephonic rounds and 4 onsite rounds.

Telephonic Rounds:

Round 1

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.

Example:
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

Round 2

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`.

Example:
input arr : [3, 6, 4, 5] and k = 4
Following are the subarrays with median >= k
[6]
[4]
[5]
[6, 4]
[4, 5]
[3 6 4]
[6, 4, 5 ]
[3, 6, 4, 5]

Onsite Rounds:

Round 1
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.

Round 2
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.

Example:
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.

Round 3

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.

Round 4
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.

My Personal Notes arrow_drop_up