Posting details of Google Virtual Onsite interview, which consisted of 4 rounds, of 45 mins each -- 3 technical and 1 behavioural. All rounds were scheduled on the same day, and it was a very smooth interview experience.
Round 1 : The interviewer was very formal and to-the-point, expecting crisp answers to every question. I was asked to design a temperature register, which would receive numerous of temperature readings at any given time and display maximum temperature received in the last 24 hours. The design should scale to handle millions of readings gracefully. The solution I offered was to use a max heap where the root node would always refer to the maximum temperature. Since my approach would result in the heap growing indefinitely, I also suggested a cleanup module to delete all temperatures periodically every 24hours. The interviewer accepted this solution and asked time complexity for every module. He then suggested this can be done via a BST as well. I feel it could have been done via a Deque too, but I think it boils down to how much it scales.
Round 2 : This was the Googleyness round. Interviewer asked some basic behavioural questions. Listing down the ones i can recall:
Round 3: You are given an array depicting heights of buildings. You can jump from one building to next, if it's height is less than or equal to the current building. If the next building's height is greater than the current one, you have to climb it. You can use either bricks or ropes for the climb. Each brick is of height 1 unit. A rope can assist you to climn any unit of height, but one rope can be used just once.
Given the number of ropes and bricks, use them optimally to jump to as many buildings as possible and return the index of the farthest building that you can jump to. For e.g.,
Input: heights = [4,12,2,7,3,18,20,3,19], bricks = 10, ropes = 2
Output: 7
I brainstormed and improved from recursive solution to a DP solution to finally a solution with heaps. That took O(nlogn). I covered all edges cases and did dry run with given set of inputs. However it took me 4minutes more than the time limit, which i feel led to deduction of points despite a proper solution. Interviewer was friendly and gave me a hint when i was thinking and i was able to catch it. She was nice enough to give me 4mins to finish the code but well :P
Round 4: Given a list of inequations, you have to find if they are solvable or not. Return true if solvable, else return false. For e.g.,
Input:
Output:
The inputs would be given as list of string arrays. The language of the question was confusing, it mentioned that the value of the variables could be anything and we are not allowed to subsitute or make any ordering based on literal values / ASCII values of characters. It took me a lot of time to figure out what is actually happening here, and in the end i finally coded the solution but it was not optimal.
Interviewer suggested in the end that this can be done most optimally using forest and topological sort.
Overall, few points which i could realise from this experience and would like to share with the community:
Hope this helps !