Google | L3 | India | Feb 2020 [Rejected]
Anonymous User
1637

I recently attended onsite interviews for SWE L3 for Google.

Round 1
Design a data structure with two operations 1. addRange(int start, int end) and 2. contains(int point)
Here range means an interval, so the data structure contains information of all ranges added uptil that point and you can have interleaved queries of the form contains(int point) which returns true if the point is contained in any of the ranges or false otherwise.

The solution I thought of was to store the ranges/intervals as a list of sorted disjoint intervals (i.e merge overlapping intervals). Now when we get a contains query, we can perform binary search(interval with start point equal to or less than point) to find a potential interval that may contain it. addRange would be O(n) and contains would be O(logn). I believe there is a better solution with interval trees but interviewer said this solution was okay which I ended up coding.
But the catch is to convince him of this solution and explain it to him took a lot of time due to back and forth with him. Tip to you guys, if you can think of the right solution just jump to it immediately, skip unnecessary details, and try to be quick but also clear in your explanation.
In my case I believe the interviewer actually had two questions and wasn't able to get to the second one.

Round 2
You have two arrays of odd length (same length). You should check if you can pair elements from both arrays such that xor of each pair is the same.
Ex : [a, b, c] and [d, e, f] check we can find a pairing say (arrays actually have integers)
a xor e = v
b xor d = v
c xor f = v

Solution
Since the length is odd, if a pairing exists like in the example above, v would be the xor of all elements in both arrays. Now a xor e = v so e = a xor v. We can store elements of one array in a map and check for every element in the other array if the corresponding required number is present.
O(n) time and space.
So I bombed this relatively simple problem. I figured out a O(n2) solution where I fix one pair and check for that v so we end up checking for n possible v's. But for some reason I totally missed the odd length part meaning theres only v that we have to search for.

Anyway I believe even this interviewer expected to ask a second question which he wasnt able to.

Only two round were scheduled for that day. My recruiter later told me that the performance was not good enough so we would not be moving with the other rounds. He said the earliest I could apply again was after a year.

Thing is I prepared decently for the interviews (210 LC) and it kinda sucks that i got prematurely rejected. The questions werent over the top at all but I didnt have a good day.

My takeaways for you guys

  1. While practicing aim to do easy/medium level questions in 20 minutes max (while timing grab a whiteboard speak out loud explaining the solution to yourself and then code it out). I find it surprising but atleast in india, it looks like the interviewer is actually expecting to fit in two questions in a 45 minute interview.
  2. While practicing, make it a habit to ALWAYS write clean bug free code, meaning it should run in the first go. Do not develop a habit of writing so quickly and relying on the compiler to catch your silly bugs which you end up fixing run after run. Avoid the silly bugs in the first place and this will translate to you writing clean code on your interview day.

I hope the post has been atleast slightly helpful.

Finally some questions for you guys. I believe with smarter practice I should be able to crack it next time. Is it really normal for people to have multiple attempts. What if the initial attempt was a disaster like in this case. Do I actually have to wait a complete year before I try again.

Comments (3)