Directi interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Directi
upvote
share-icon
3 rounds | 10 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 5 months
Topics: Data Structures, Algorithms, System Design, Aptitude, OOPS
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

Application process
Where: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration90 minutes
Interview date19 May 2015
Coding problem2

The test comprised of general aptitude + technical questions (C, OOP, DBMS).
Aptitude questions (with a few exceptions)were easy, technical questions were of moderate difficulty. C questions like recursive functions, finding output of some code etc.

1. Maximum Sum Path Of A Binary Tree.

Hard
25m average time
75% success
0/120
Asked in companies
HikeSamsungDirecti

You are given a binary tree having 'n' nodes. Each node of the tree has an integer value.


Your task is to find the maximum possible sum of a simple path between any two nodes (possibly the same) of the given tree.


A simple path is a path between any two nodes of a tree, such that no edge in the path is repeated twice. The sum of a simple path is defined as the summation of all node values in a path.

Problem approach

One approach would be to traverse the tree and for every traversed node X :
1) Find maximum sum from leaf to root in left subtree of X 
2) Find maximum sum from leaf to root in right subtree of X. 
3) Add the above two calculated values and X->data and compare the sum with the maximum value obtained so far and update the maximum value. 
4) Return the maximum value.

The time complexity of above solution is O(n2)

This question can also be solved in a single traversal of binary tree. The idea is to maintain two values in recursive calls : 
1) Maximum root to leaf path sum for the subtree rooted under current node. 
2) The maximum path sum between leaves (desired output).

For every visited node X, we find the maximum root to leaf sum in left and right subtrees of X. We add the two values with X->data, and compare the sum with maximum path sum found so far.

Try solving now

2. Minimum Number of Platform Needed

Easy
23m average time
85% success
0/40
Asked in companies
Thought WorksGoldman SachsIntuit

You are given the arrival and departure times of N trains at a railway station in a day. You need to find the minimum of platforms required for the railway station such that no train waits i.e No train should wait for the platform to be clear or free.

Problem approach

This is just a problem to find the max overlap of segments. 
A quick solution is :
1. sort all coming time with leaving time 
2. Scan the sorted list, if it is coming, +1, if it is leaving, -1. And record the max number. 
That is the answer. 
Time Complexity: O(2Nlog(2N)) 
Space Complexity: O(2N) + sorting space

Try solving now
02
Round
Medium
Face to Face
Duration60 minutes
Interview date19 May 2015
Coding problem3

The first round was algos round. Panel consisted of one interviewer. He asked me to tell him about myself. Then, he asked if I had passion for something. I talked about web development and we had a very long discussion on many web technologies, protocols, interoperability, vendor locking, cloud storage, cloud computing, web OSes, domains, DNS, server technologies, web databases. This is where I scored huge points in my interview. Then he asked some programming questions.

1. Excel Column Number

Easy
23m average time
0/40
Asked in companies
OptumAppleOracle

You have been given a column title as appears in an Excel sheet, return its corresponding column number.

For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28 
...
Problem approach

For every additional digit of the string, multiply the value of the digit by 26^n where n is the number of digits it is away from the one's place. 
This is similar to how the number 254 could be broken down as this: (2 x 10 x 10) + (5 x 10) + (4). For this question, 26 will be used as a base instead of 10. 
For s = "BCM" the final solution would be (2 x 26 x 26) + (3 x 26) + (13)
This process can be carried out iteratively. Start at looking at the first character of the string. Add the integer equivalent of that character to the running sum and continue. For every new character, multiply the running sum by 26 before adding the new digit to signify we are changing places.

Try solving now

2. Merge K Sorted Arrays

Moderate
15m average time
85% success
0/80
Asked in companies
MathworksMicrosoftOracle

You have been given ‘K’ different arrays/lists, which are sorted individually (in ascending order). You need to merge all the given arrays/list such that the output array/list should be sorted in ascending order.

Problem approach

A simple approach would be to create a new arrays with size as sum of the sizes of both the arrays. Copy the elements of both the arrays in the new array and sort the array. 
A space optimized approach also exists. While traversing the two sorted arrays parallelly, if we encounter the jth second array element is smaller than ith first array element, then jth element is to be included and replace some kth element in the first array. 

Algorithm
1) Initialize i,j,k as 0,0,n-1 where n is size of arr1 
2) Iterate through every element of arr1 and arr2 using two pointers i and j respectively
if arr1[i] is less than arr2[j]
increment i
else
swap the arr2[j] and arr1[k]
increment j and decrement k
3) Sort both arr1 and arr2

Try solving now

3. Puzzle

Probability of getting K heads in N coin tosses

Problem approach

Probability of getting K heads in N coin tosses can be calculated using below formula: 
1/(2^n)) * (n! / ( r! * (n-r)!))

03
Round
Medium
Face to Face
Duration105 minutes
Interview date19 May 2015
Coding problem5

This was my longest and toughest interview yet. He asked a programming question first. Then he asked me questions on javascript, PHP, mySQL.Then there were questions on OS (like multithreading) and networks (OSI model, TCP/IP model, DNS functioning, IMAP, POP, protocols, encryption etc)

1. Minimum Jumps

Moderate
25m average time
75% success
0/80
Asked in companies
WalmartDirectiMakeMyTrip

Bob lives with his wife in a city named Berland. Bob is a good husband, so he goes out with his wife every Friday to ‘Arcade’ mall.

‘Arcade’ is a very famous mall in Berland. It has a very unique transportation method between shops. Since the shops in the mall are laying in a straight line, you can jump on a very advanced trampoline from the shop i, and land in any shop between (i) to (i + Arr[i]), where Arr[i] is a constant given for each shop.

There are N shops in the mall, numbered from 0 to N-1. Bob's wife starts her shopping journey from shop 0 and ends it in shop N-1. As the mall is very crowded on Fridays, unfortunately, Bob gets lost from his wife. So he wants to know, what is the minimum number of trampoline jumps from shop 0 he has to make in order to reach shop N-1 and see his wife again. If it is impossible to reach the last shop, return -1.

Problem approach

Approach 1 : Naive Recursive Approach

A naive approach is to start from the first element and recursively call for all the elements reachable from first element. The minimum number of jumps to reach end from first can be calculated using minimum number of jumps needed to reach end from the elements reachable from first.

minJumps(start, end) = Min ( minJumps(k, end) ) for all k reachable from start

TC : O(n^n)
SC:O(n)

Approach 2: Dynamic Programming - Tabulation

We can solve this iteratively as well. For this, we start from the last index. We need 0 jumps from nums[n-1] to reach the end. We store this as dp[n - 1] = 0 and then iteratively solve this for each previous index till the 0th index. Here dp[i] denotes minimum jumps required from current index to reach till the end.
1) For each index, we explore all the possible jump sizes available with us.
2) The minimum jumps required to reach the end from the current index would be - min(dp[jumpLen]), where 1 <= jumpLen <= nums[currentPostion]
TC : O(n^2)
SC : O(n)

Approach 3 : Most optimal - Greedy-BFS

We can iterate over all indices maintaining the furthest reachable position from current index - maxReachable and currently furthest reached position - lastJumpedPos. Everytime we will try to update lastJumpedPos to furthest possible reachable index - maxReachable.
Updating the lastJumpedPos separately from maxReachable allows us to maintain track of minimum jumps required. Each time lastJumpedPos is updated, jumps will also be updated and store the minimum jumps required to reach lastJumpedPos (On the contrary, updating jumps with maxReachable won't give the optimal (minimum possible) value of jumps required).
We will just return it as soon as lastJumpedPos reaches(or exceeds) last index.

TC : O(n)
SC: O(1)

Try solving now

2. Buy and Sell Stock

Hard
0/120
Asked in companies
Samsung R&D InstituteMicrosoftSalesforce

You are Harshad Mehta’s friend. He told you the price of a particular stock for the next ‘n’ days.


You are given an array ‘prices’ which such that ‘prices[i]’ denotes the price of the stock on the ith day.


You don't want to do more than 2 transactions. Find the maximum profit that you can earn from these transactions.


Note

1. Buying a stock and then selling it is called one transaction.

2. You are not allowed to do multiple transactions at the same time. This means you have to sell the stock before buying it again. 
Example:
Input: ‘n’ = 7, ‘prices’ = [3, 3, 5, 0, 3, 1, 4].

Output: 6

Explanation: 
The maximum profit can be earned by:
Transaction 1: Buying the stock on day 4 (price 0) and then selling it on day 5 (price 3). 
Transaction 2: Buying the stock on day 6 (price 1) and then selling it on day 6 (price 4).
Total profit earned will be (3 - 0) + ( 4 - 1) = 6. 
Problem approach

The idea is to traverse the given list of prices and find a local minimum of every increasing sequence. We can gain maximum profit if we buy the shares at the starting of every increasing sequence (local minimum) and sell them at the end of the increasing sequence (local maximum). 
Steps :
1. Find the local minima and store it as starting index. If not exists, return.
2. Find the local maxima. and store it as an ending index. If we reach the end, set the end as the ending index.
3. Update the solution and Increment count of buy-sell pairs. 
4. Repeat the above steps till the end is not reached.

Try solving now

3. Networking Question

What is an IP address?

Problem approach

An IP address is a unique address that identifies a device on the internet or a local network. IP stands for "Internet Protocol," which is the set of rules governing the format of data sent via the internet or local network.

In essence, IP addresses are the identifier that allows information to be sent between devices on a network: they contain location information and make devices accessible for communication. The internet needs a way to differentiate between different computers, routers, and websites.

4. Networking Question

What is a MAC address?

Problem approach

MAC address is the physical address, which uniquely identifies each device on a given network. To make communication between two networked devices, we need two addresses: IP address and MAC address. It is assigned to the NIC (Network Interface card) of each device that can be connected to the internet.
It stands for Media Access Control, and also known as Physical address, hardware address, or BIA (Burned In Address). It is globally unique; it means two devices cannot have the same MAC address. It is represented in a hexadecimal format on each device, such as 00:0a:95:9d:67:16. It is 12-digit, and 48 bits long, out of which the first 24 bits are used for OUI(Organization Unique Identifier), and 24 bits are for NIC/vendor-specific.

5. Basic HR Questions

How can I contribute to Directi?
What exactly did I do in my internship and how did I benefit my team?

Problem approach

Tip 1 : The cross questioning can go intense some time, think before you speak.
Tip 2 : Be open minded and answer whatever you are thinking, in these rounds I feel it is important to have opinion.
Tip 3 : Context of questions can be switched, pay attention to the details. It is okay to ask questions in these round, like what are the projects currently the company is investing, which team you are mentoring. How all is the work environment etc.

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

What is recursion?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
1 rounds | 3 problems
Interviewed by Directi
803 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 4 problems
Interviewed by Directi
0 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 7 problems
Interviewed by Directi
872 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 4 problems
Interviewed by Directi
0 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
114579 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
57825 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
34961 views
7 comments
0 upvotes