Process
Applied for the SWE Role at Bangalore and Hyderabad offices on Google’s Career Site. Soon after 2 weeks a recruiter reached out for a phone conversation with me.
HR Phone Screen [45 mins]:
Mostly intro, about this role, my experience related and expectations from role related questions with basic 8-10 technical mcqs on ds-algo-maths and finally some prep related discussion. In the end I was asked for five slots for next phone interviews.
Technical Phone Screen [45 mins]:
[1.5 months later]
Just one Algorithmic Question: Given 2 strings of hexadecimal digits, return a string containing hexadecimal digits of their sum. For example, add_hex("12", "18") returns "2a".
The functional code for the above problem was to be written on shared google docs.
Approach: Used 2 pointers to traverse strings from the end and adding digit by digit to get the result
Result: After 2 days I was informed that I was selected for the onsites.
Round 1: Behavioural
Round 2: Technical
Eg. say we have an
array of blocks - [0, 0, 1, 1, 1, 1, 0, 1, 0]
jump range= [2, 5]
ans: true
explanation: 0 -> [ jump to next block ] 1 -> [ jump on i+5 ] 6 -> [ jump on i+2] 8 [Reached]
Eg. for array [0, 1,1,1,1,0] , range = [2,3], ans: false
Approach: Solved with Memoization from end of the arr, checking from which indices its possible to get to any index ‘i’, then tried to do this recursively for every possible index till we get to the index 0.
PS: Time Complexity for my solution was O(N^2) with space complexity of O(N).
Round 3: Technical
Eg. for above config - [1,2,2,2,1,1,3] -> burst the candies with 2,2,2 cluster -> [1,1,1,3] -> burst the candies with 1,1,1, which is newly formed -> [3]
Thus the only answer for the above config of candies is [3].
Eg. for config - [1,1,1,2,2,2,1], you can burst either first cluster with [2,2,2] or [1,1,1].
thus one of the answer will be [] if [2,2,2] is crushed first and then cluster with [1,1,1,1]
Approach: My approach for this was similar to the one for the Q. below using Stack and Compression - https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/
PS: Time Complexity for my solution was O(N) with space complexity O(N) for both.
Round 4: Technical
Eg. if we have a 3x3 matrix as follows -
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
Lets say threshold is 3.
Result: true
One of the path is : 1 -> 2 -> 5 -> 8 -> 9. the abs differences of the adj cells in this path is - [1, 3, 3, 1], max of them is 3 => thus the path has an effort 3.
Approach: I discussed and coded the Brute force solution discussing as to how the time complexity will be exponential, it was backtracking based solution.
PS: Time Complexity for my solution was Exponential for both Questions.
Round 5: Technical
Eg: say building from floor 0 to N (left to right) - [ 0, 1, 2, 3, 4 ] (Ignore the array values, those are just the floor numbers for reference)
, X=0, Y=4, jumps=[3, 1]
result: 2
explanation: 0 -> 3 [up] -> 4 [up]
Eg: building - [0, 1, 2, 3, 4]
X=1, Y=4, jumps=[3,1]
result: 2
explanation: 1-> 4 [up] -> 3 [down]
Approach: One approach that I thought was, suppose if floor Y is above X and that it is not possible to directly reach Y with few ‘up’ jumps then, starting from Xth floor we continue to use the ‘up’ no. of jumps until we pass the Yth floor, once Y is passed then check the diff between Yth and current floor. If the diff is divisible by down then its the min. ans, else keep on adding jumps to the current floor till the diff is not divisible by ‘down’. We also start to keep track of the remainder of division [diff / down] every time ‘up’ is added in current floor after Yth floor is surpassed. If at any time the remainder that we get is visited earlier then we are getting into loop and need to stop. Apply this same approach when Yth floor is below X, up and down values are changed, else everything remains the same. This approach has O(N) time and O(N) space complexity in the worst case. I coded this solution and then interviewer again modified the Q.
Approach: After discussion, the interviewer gave a hint to think about and traversals, and then I came up with the BFS solution. Here if we are at ith floor with x jumps then there are 2 choices going at (i+up)th floor and (i-down)th floor in x+1 jumps if those floors are unvisited. So this is true for every floor when starting to traverse from floor X. Do this until we get till floor Y. If reaching the floor Y is not possible even after visiting all the possible floors, then its not possible to reach. Else the count of jumps when the floor Y first is visited in BFS traversal will be the min. jumps as required.
PS: Time Complexity of my solution for the last Q. was O(N) for preprocessing and then O(1) for each query, with Space Complexity of O(N).
Results:
After a month later recruiter called, said that the reason for my rejection was that I had mixed feedbacks, 60% positive and 40% negative sort of, was also informed that coding quality could have been better, was able to arrive at solution but needed a lot of hints and said that I struggled with the speed of solving problem. Apart from that even though I was able to communicate my thought process very well & knew how Solution would look like, it didn’t convert into when I started to code it on the chromebook.
Preparation:
Practised for around 2 and a Half months before on-sites.
Solved 159 LC problems - 11 easy | 108 Medium | 40 Hard
GFG for basic ds algo top topics,
LINK: https://www.geeksforgeeks.org/interview-preparation-for-software-developer/
Tushar roy Youtube Channel for solutions - https://www.youtube.com/user/tusharroy2525
Feel free to explore and see what best suites your prep needs.
Additionally you can refer to -
https://github.com/donnemartin/system-design-primer#index-of-system-design-topics
youtube playlist https://www.youtube.com/playlist?list=PLkQkbY7JNJuBoTemzQfjym0sqbOHt5fnV
for basic system design prep.