Google Interview Experience SWE FTE ( On-Campus 2024 )

Last Updated : 27 Sep, 2024

Online Assessment Round

Duration - 60 minutes

Questions - 2 from a set of 8 Questions for the test happening PAN India. 6 Questions were medium, 2 were hard.

Round - 1: Technical Round (45 Minutes)

Q1: Given N friends, each friend remembers some subsequence of an array. Check if such an array exists, if yes, find any possible array.

friend[0] = {1, 4, 2}, friend[1] = {2, 5, 3}, friend[3] = {1, 2, 3}, friend[4] = {4, 2, 5, 6}

One possible array satisfying each condition: {1, 4, 2, 5, 3, 6}

Solution: This is a classical problem of Topological Sort. I explained BFS and DFS approaches for this and write code for both also. This was completed within 20-25 minutes. The interviewer was super impressed by the speed. The interviewer came with only 1 question, so she asked around 5-6 easy questions after this.

This interview ended within 35 minutes.

Round - 2: Technical + HR Round (60 Minutes)

Question 1: The farmer owns an N x M meter field and is facing financial challenges. He's considering selling most of the field but wants to keep a 3x3 section while conserving water usage. Each 1 x 1 plot needs a specific amount of water. Your task is to identify the optimal 3x3 slot for him, considering water efficiency.

(Given a NxM matrix, find the minimum sum of 3x3 sub-matrix.)

Example: Given matrix:

[

1,2,3,4,5,4,

3,1,2,1,0,4,

2,6,7,0,1,1,

4,6,7,0,0,1,

1,2,4,6,2,3,

2,7,9,8,1,5,

]

for the sub-matrix [ (row=1, coloumn=3) to (row=3, column=5)], the sum is 8 and this is the minimum 3x3 cells.

Solution : This is also a classical problem of prefix sums. I started with a prefix sum based solution. Interviewer asked me to optimise the code to O(1) space complexity. After this, he came up with a follow up question .

Question 2 : Consider a situation where you are given matrix sizes NxM, but some plots have a value of zero. Your task is to find the minimum 3x3 plot on this grid where all 9 plots have a non-zero value.
Solution : This is also a similar problem, where we just need to track the zeroes. I write code with time complexity = O(n * m) and space complexity = O(m).

Then, interviewer asked 3-4 general situation based questions. Interview ended in around 50 minutes.

Round - 3 : Technical + HR Round (60 Minutes)

Question : Consider a game called "The Odd One Out": You're given a list of words, and you have to figure out which word is the "odd one out", or the least similar word. For example, given "red, blue, green, cow, yellow", the odd one out is "cow", because it is an animal, not a color.

Write a function that given a list of words, determines which one is the odd one out.

You also have access to a universe of words, where each word comes with a set of words that are its attributes.

For example, "cow" has the following attributes: "animal, mammal, white, etc.".

cow - "animal, mammal, white, etc.".

table - "furniture, legs, brown"

kitten - "baby, cat, pet, white"

Input:-

table - "furniture, legs, brown, books"

bed - "furniture, legs, brown"

chair - "furniture, legs, yellow"

study table - "furniture, legs, black, books, lamp, computer, paper"

Solution : This was a tricky question to understand, I was not getting how exactly odd one is to be filtered. Then, I discussed many examples with interviewer to get better understanding of question. Then got to know, function need to return that object, after removal of which, rest all objects has maximum number of common properties.

Initially, I came up with DSU based approach but it didn't worked. Then, I came to solution using prefix and suffix based approach. I used prefix and suffix array of set, ( let's say we are at index 'i', then prefix[i] will be a set which will contain all properties common in objects from index 0 to i, and suffix[i] will be a set which will contain all properties common in objects from index i to n-1. )

Then we iterate through each object, and check how many properties are common in all objects, if we remove 'i'th object by merging prefix[i-1] and suffix[i+1], the index where we get maximum size of this merge, will be our answer.

This approach was correct, I wrote code for the same, this took around 40 minutes. Then, interviewer asked 3-4 Googliness questions.
This interview ended in around 55 minutes.

Comment