Years Of Exp : 2 years in MNC
Preparation : 3-4 months (400+ leetcode questions)
Date : May-June 2021
Round 1 : Phone Screening
Scenario:
Imagine we wanted to build a new feature into Google Maps where we help people plan road trips. As an example, a user might be trying to make it home in time for the holidays.
For the minimum viable product (MVP) ...
You know
The distance between each stop you want to make along the way
How much time you have to get to your destination (in hours)
But
You can only drive at one speed the entire trip
Even if you finish one stretch early (e.g. 25 miles going 50mph), you CANNOT start the next stretch in the same hour
Question:
Write a function that returns the minimum speed (distance per hour) you can drive across the entire trip and still arrive on time.Examples:
minDrivingSpeed([3,6,7,11], 8) => 4 because:
Cover distances[1] in Hours 2 & 3
Cover distances[2] in Hours 4 & 5
Solution :
Interviewer have not explained complete question. It takes me 10 - 15 min to fully understand this problem. I had asked many clarifying questions.
After that I was able to slove this problem using binary search in next 10 -15 min. Interviewer agreed and asked me to write code.
I have completed code in next 10 min then he asked me to run for some test case and it was working. TC : O(nlogn)
At end 5 min left and he aked me if i have some question. I had asked some basic questions.
Feedback:
Result : +ve
Positive : Communication, Code quality, DSA skill
Negative : took more time to comeup with first algorithm.
Now next 4 rounds scheduled.
Round 2 : Technical
Interviwer told me that he would ask only one question in this round.
Question :
Find path from 'CEO' to an Employee
Employee{
String name;
String metadata;
List<Employee> reporters; // list of employee who reportes to this employee
}
List<Employee> findPath(List<Employee> employees , Employee e){
//. need to return path from ceo to employee e
Ex : a-> b-> c-> d-> e
assume a is ceo
}Note : CEO is an Employee who does not reports to any other employee
Solution:
I had given one solution using DFS.
Steps
Find ceo using dfs traversal and boolean manager map.
Map<Employee, Boolean> manager; // let 'a' be ceo then manger(a) will be false
Find path using dfs from 'ceo' to 'e'
Interviewer aggreed with this approach and asked me to write code. I had completed this code in next 10-15min.
Once i said i completed time was 30-35min. He was looking at code for 2-3 min but did not say anything. After 5 min i asked it this clear to you or shound i test with some sample test case, He said "yes please it will be better".
I dry run with sample test case and it was working after some minor modification(like HashSet Data type)
Round 3: Technical
Question
GIven inequality, return true if it is possible otherwise false
boolean isPossible(List<List<String>> triplets){}
Ex : [["a", ">", "b" ], ["b", "<" "c"], ["c","<" ,"d"]] : True
[["a", ">", "b" ], ["b", ">" "a"]] : False
Constraints :
1 . We have only < , > inequality
2. variables(Ex, a b etc) can be any real noI understood this problem quickly and provided the soultion using dfs[ is cycle present or not in directed graph ] as well whithin 10 min. Then he asked me to write code. I completed code in next 5 min. He asked me to dry run with same input and asked time complexity : (O(n))
Now we have 25 min left, he asked in followup question on this.
Question :
Instead on letter we can have numbers as well in this triplets.
Ex : 5 > a, 6 > b, a < b : True
I had asked some clarifying question here and try to solve it. I devided inputs in 3 parts.
1st was already solved, 2nd was straight forward just o(1) operation to say True or false
3. I tried a lot and comeup with following solution
I said that i will add literals pair as well in input. Ex : 5 > a, 6 > b, 7 < d. : then we need to add 5 < 6, 5 < 7, 6 < 7
if we have 'k' unique numbers we need to add kC2 more triplets. then apply same also.
interviewer aggreed. Now its arround 43-44 and so we have ended this round after asking some basic questions.
Round 4 : Technical
Find shortest path from city A to city B and print the path as well. Shortest path means min no of nodes in the path.
List<String> getShortestPath(String source, String distination)
Class City{
String name;
List<String> adj;
}Solution :
Approach 1 : Using backtracking
Approach 2 : Using BFS with parent Map. TC : O(V+E)
Interviewer agreed with second approach and asked me to write code. I completed the code in next 10-15 min.
He asked in to run with sample test case. It was working. Time over so ended this round.
Round 5 : Behavioural
Some question along with followp
Share situation where
Feedback :
Result : -ve
Area of improvement : Coading speed
Note :
Hope this help :)