谷歌暑期实习 2020

Status: Student, Bachelor’s in EE+CS
Date: 4th + 5th Nov, 2019
Type: Technical phone screen (45 minutes each on 2 consecutive days)

Interview 1:

-Mentions a little about his role at Google and how he’d worked on something similar to a project on my CV during his own undergraduate years
-Asked a single question: Assume that in an alternate reality, we use C++ (my preferred language) instead of HTML/other scripting languages to design webpages. Design a class to which allows us to blink an object on screen at some given frequency (apparently there is some HTML tag that let’s you do this? I had no idea).

Comment: I have been a competitive programmer for almost an year now and did a fair bit of interview specific algo/DS questions to prepare for the interview from leetcode, but this question really caught me off-guard. It wasn’t just the nature of the question but also the large amount of skeleton code that he quickly wrote on the doc for me to use. And while I have been coding in C++ for years now, I honestly know only that limited portion of the language which is used in competitive programming and nothing more than that. I wasn’t super comfortable with desigining classes and subclasses and employing OOP paradigm in coming up with my solution.

Secondly, while I came up with the idea of exploiting the fact that a computer would in general spend about a second in performing ~10^8 calculations, and using that as a way to keep track of the time, the interviewer commented on my solution and how it essentially runs throughout the duration of the blinking process and blocks the main thread (something like that, not entirely sure since it was the first time I was hearing about it myself)

After some back and forth discussion, I started to make use of the clock() function to keep a track of time and do something along the lines of:

counter = 0 //stores how many times the object was visible on screen
while (1)
{
	if (counter == PERIOD_OF_BLINKING)
		break;
		
	initial_time = clock();
	current_time  = clock();
	
	while (current_time-initial_time < DURATION_OF_VISIBILITY)
	{
		current_time = clock();
	}
	//toggle the visibility
	if (is_visible()) counter++;
}

However, this solution again kept running throughout the duration of the program and hence didn’t satisfy him. Finally I made use of the timeout() function that he had declared in his code at the beginning because he mentioned at some point in the middle of the interview that the way his timeout function is implemented, it wouldn’t take up memory or processing power (?) and hence would be more efficient.

Finally he wanted me to come up with a test function to ensure the our class is working as expected, and this time learning from the previous part I decided to use the timeout() function and did something like this:

bool test()
{
	/*start the blinking using some method of the class*/
	
	timeout(DURATION_OF_VISIBILITY)
	if (getVisibility() == INVISIBLE) return true;
	else return false;
}

This implementation obviously had a flaw (where the object could have finished one blink cycle while my function was asleep from the timeout call and went invisible again by the time the control returned to my test function. I did mention it to him but by this time the interview was well past 45 minutes so he decided to wrap up. He did mention that he was expecting me to devise a child class of the blink class he had created earlier (all these functions were methods of that class) and use that child class to measure how many times the toggle visibility function was called.

In the end, I’d probably guess I fared below average and really wasn’t satisfied with either the question or my performance. The interviewer was cool and communicative, but again the type of question he asked really left me confused for much of the interview duration. Honestly felt this would have fit better in an interview for someone with experience instead of an internship experience, but can’t really do anything about it.

Interview 2:

Again asked only a single question, but before the question even started, he mentioned how he’s okay with any working solution, doesn’t necessarily have to be the most optimized one.
Question goes like:
You have a grid with dimensions m x n where each element in the grid can either be a 1 or a 0. You have the ability to choose any element and flip it’s value. The only condition is that when you choose to flip any element at index (i, j), the 4 neighbors of that element (at (i+1,j), (i-1,j), (i, j+1), (i,j-1)) also get flipped. Find the minimum number of flips that you need to do in order to set all the elements in the matrix equal to 0. If it’s not possible, return -1.

Comment:
-In order to secure some brownie points, I decided to ask some clarifying questions (the original question he gave was very vague, I had to ask him additional questions to get the information provided above). But the replies were not exactly very precise so I decided to not pursue further

-The interviewer, while he did provide tips on how to proceed, seemed very uninterested in the whole interview process. He did walk me through a lot of the steps, helped me in finding the time complexity for the brute force solution, and commented on my brute force implementation. But at certain points during the interview it felt like I was just talking to myself since I didn’t hear anything from his side. Initially I thought maybe it’s because he’s focussing on what I am typing, but even after asking him something like “Am I going in the right direction?”, or “what do you think?”, it sometimes took him almost 10 seconds to even respond to my question. Finally his accent was also pretty heavy (east European/russian) so it made it even more difficult for me to follow him at times.

-Overall, I guess I performed below average in this interview as well, even though I think irrespective of the interviewer and his style, this problem was solvable. There were some bugs in my brute force implementation as well which he did point out.

Combined, I really don’t think I’ll be getting an offer anytime this year. Will continue to focus on leetcode and hope to get some standard algorithmic questions next time :slight_smile:

报个我的店面题目

Given a binary 2D grid (each element can either be a 1 or a 0). You have the ability to choose any element and flip its value. The only condition is that when you choose to flip any element at index (r, c), the 4 neighbors of that element also get flipped. Find the minimum number of flips that you need to do in order to set all the elements in the matrix equal to 0. If it’s not possible, return -1.

Example 1:

Input:
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]

Output: 0
Example 2:

Input:
[[0, 1, 0],
[1, 1, 1],
[0, 1, 0]]

Output: 1
Explanation: Flip (1, 1) to make the whole matrix consisting of only 0s.

我挂了,考了这题

Given an array of integers, find the second max using only the function compare(a,b) that compares two integers and retunrs the maximum of the two. The solution must use the function compare(a,b) a minimum amount of time.

报1道看到的面经题

I had a Google phone screen last week with a Google software engineer. He was a team lead at Google from a few years. We went directly in the coding question after greeting each other. No questions about the resume or my background. The question was, given 2 points in a 2d array of all 0s, generate a random walk and return the grid.
Every time a random walk should be returned (the bigger the better, but not necessary). You can walk in the 4 directions up, down, left and right.

eg.
[
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
]

You can mark a position 1 when you have stepped over that position.
assume the start was (0, 0) and end was (3, 3).

The paths can be
[
[1 1 0 0]
[0 1 1 1]
[0 1 1 1]
[0 0 0 1]
]

The above path goes (0,0) - > (0,1) - > (1,1) - > (2,1) - > (2,2) - > (1,2) - > (1,3) - > (2,3) - > (3,3)

Every time a random walk should be returned.

I tried to play along these lines : https://www.geeksforgeeks.org/random-walk-implementation-python/
But I could not give a final solution for a 2D array.