Recruiter reached out to me on Dec 2021 about the opportunity.
Screening round 1:
Given a bunch of java files which import other java source files, print the order of files from least dependent to most dependent.
Ex:
A : B C D (A imports B, C, D)
B : C D
Output : C D B A
I proposed DFS + topology. DFS for cycle detection and topology sort for printing out the order.
Feedback : It could have been solved by either DFS or Topology. My solution was not optimal. Mixed feedback. Hence Recruiter asked me for another screening round.
Screening round 2:
Given two integer streams, interface is described as below -
class IntegerStream {
public:
int next() {
// logic
}
bool hasNext() {
// logic
}
};
Implement the logic where the constructor of your class will accept two integer streams and you have to implement next(), hasNext() method.
Example:
IntStream1 : 3 6 7 9
IntStream2 : 2 3 5 7
calling next() will print the below as one sequence -
3 2 6 5 7 9
class IntStreamMerger {
public:
int next() {
// implement your logic here
}
bool hasNext() {
// implement your logic here
}
};There is a similar leetcode problem 284: Peeking Iterator . It just needed some tweaking.
Feedback : Positive, qualified for 1st onsite
First onsite:
Round 1
There are traffic lights on each cell of a (m x n) matrix. Each cell of matrix contains the time when the red light turns green. A self driving car starts from (0, 0) and it will reach the destination (m-1,n-1). Find out the minimum time to reach the destination.
I went with BFS where the queue will be priority queue determining which cell to go first based on when it will turn green. I was trying to explain that the priority will be determined based on waiting time for each cell. That will lead to O(mnlog(mn)) complexity. I was suggesting for a lambda function which will read the value from the grid and calculate the priority. The interviewer was most familier with java and said comparator takes argument from queue, hence no way to read value from Grid. I could not convince him for O(mnlog(mn)) complexity.
Feedback : Leaning towards negative
Round 2:
Price of a given stock is coming from time to time. The query are as follows:
What is the maximum value of the stock?
What is the minimum value of the stock?
What is the latest value of the stock?
Correct the stock price for a given point of time
Delete an erroreneous stock at a particular time
Example:
Time Price
t1 20
t2 40
t3 25
t4 10
Max value: 40, Min value: 10, Latest value: 10
Correct the price at t3 as 5
t1 20
t2 40
t3 5
t4 10
Max value: 40, Min value: 5, Latest value: 10
Delete the erroneous price at t2
t1 20
t3 5
t4 10
Max value: 20, Min value: 5, Latest value: 10I was complicating the solution too much and didn't reach out to the correct solution at that moment.
Feedback: Strong negative
Round 3:
Given subsequences of an array of integers where every element is distinct, the task is to check if there exist an unique array, and you are supposed to find the original array.
E.g -
Subsequence - [[1,2], [1,3]]
There exists 2 array [1,2,3] and [1,3,2], which could be built from the above subsequence
Subsequence - [[1, 3, 4], [1,2,3]]
Only one array exists [1,2,3,4] which could be built from the above subsequence
I suggested for topology sort.
Feedback: Strong positive
Recruiter reached out to me for 2nd onsite. I asked her if I will be downleveled as L3, since my 1st onsite was not good. She said I have 50-50 chance for L4 if I do well in 2nd onsite. I agreed for 2nd onsite.
Second onsite:
Round 4:
Given a set of different elements, the input will be an array of combination of intersection of set elements. You need to find out the cardinality of union of the input given.
Example:
Input: [A, AnB]
Output: |A|
Input: [A, BnC]
Output: |A| + |BnC| - |AnBnC|
There is a cardinality formula for set operations:
|AUB| = |A| + |B| - |AnB|
Putting the above formula for input1:
|AU(AnB)| = |A| + |AnB| - |AnAnB| = |A| + |AnB| - |AnB| = |A|I suggested subset iteration approach as below.
If there are 3 elements A, B, C in the set, the cardinality of |AUBUC| wil be as follow:
|AUBUC| = |A| + |B| + |C| - |AnB| - |BnC| - |AnC| + |AnBnC|
By subset iteration, we will arrive the above expression as -
1 0 0 : |A|
0 1 0 : |B|
0 0 1 : |C|
1 1 0 : |AnB|
0 1 1 : |BnC|
1 0 1 : |AnC|
1 1 1 : |AnBnC|
Another thing we notice is, for odd set bit, sign is positive, and for even set bit, sign is negative
By using a simple hashmap, we can arrive at the desired answerFeedback : Strong positive
Round 5:
It was googlyness round. Pretty much everything from Amazon LP.
Feedback : Slightly positive.
It was a no hire decision from Hiring Committee.
Although I prepared 700+ questions from Leetcode, I found google interview really tough.
HR was super helpful and it was a nice interview experience. No doubt Google is one of the best company in the market.