Status: 10+ years experience with well known companies
Position: unknwon
Location: Mountain View, CA
Date: January 28, 2020
Onsite ( 5 Rounds)
Google onsite questions:
Programming Round 1
You have an array populated by only 1 and 0. For all the zeros find the count of possible subarrays.
eg. [0.0,0,1,0,1]
lets rename the zeros with their indices [0,1,2, 4]
subarrays [ [0], [1], [2], [4], [0,1], [1,2], [0,1,2]]
count = 7
What is the time complexity of your proposed solutionWhat is the space complexity of your proposed solution
//I was solving it in a very tedious way, finding the real subarrays instead of just focusing on the count//but the interviewer gave me a major clue
//time complexity O(n)//Space complexity O(k)
Programming Round 2
How will you find if an undirected graph has any cycles or not.
I proposed some brute force solutions that were really really inefficientInterviewer asked if I had heard of DFS.Using that it became a very simple solution ( at least I think so).I sorta ran out of time at the end so the interviewer didn't get a chance to really walk through my solution and test.
//Assumed graph structure
//Array of nodes;
//each node is [ node name, [node names which have an edge connected to this node]]
Programming round 3
Q1 Given a binary search tree and an integer denoting the level, how will you find the largest value at that level.
//I proposed finding the rightmost node at that level recursively and interviewer seemed to agree
Programming round 3
Q2 Implement a function to return division of two integers upto given decimal places in the form of a string.
follow up question: if there were no place given how will you figure out if this division will not terminate
System Design Round
What are some of the design considerations you will have in implementing a distributed cache?It could be accessed worldwide.
We want High availability, Low latency
Mostly used for reads
Followup questions -
What happens when requests miss in the cache?
How will you handle replacements when the cache is full?
How will you handle spikes where way too many reads are coming for the same thing
how will you save your servers from hotspotting?
What are some of the abuse scenarios you can think of? How will you protect against those?
What is sharding.
Behavioral round------------------
Q. What qualities do you look for in your colleagues?
q. Tell me about a time whne you had to deal with a difficult colleague, classmate?
Q. Tell me about a time when you took a risk
Q. How will you make your work accesible for a diverse set of people ( disabled, speaking different languages etc)
Q. How do you make sure that your work is more useful for customers
Q. If your manager gave you some project but didn't give you any other details ( they may be too busy or not have all the info themselves) how will you go about building it
Result: Rejection