Google, Bangalore | L4 | Phone Screen | Reject | Bad experience
Education : Tier-1
YOE = ~7
Interviewer told, it's a warm-up question :
Beautiful Path: You're given a footpath of n blocks, each painted with one of k colors. Guests walk along the path, and each has a favorite color c. The beauty of the path for a guest is the length of the longest contiguous footpath segment painted in their favorite color.
block_colors = {6, 5, 2, 1, 2, 2, 3, 4, 5, 2}
c = 2
k = 6 (I realised it's not required in logic)
Q. Find the longest continuous streak of color c.
I had 2-Pass approach in mind that time. Later, after the interview I realised a simple iteration could've solved it.
My Approach which I had thought :
Phase 1: Preprocessing
Phase 2: Post-Processing
Dry run :
blocks = [6, 5, 2, 1, 2, 2, 3, 4, 5, 2]
c = 2
Step 1: Find indices of all non-c blocks
Step 2: For each pair of adjacent non-c indices, the c block streak lies between them :
Check gaps between:
I know it's a bit indirect compared to direct sliding window.
How I approached?
After telling brute force method for 2-3 mins, I tried discussing edge cases first to which the interviewer told to ignore as of now. Then I thoguht for 2 mins & started discussing the above non_c approach, but she told me why you are dicussing non-c approach I told, it will help in finding the continuous gaps. But she wanted to proceed with counting c blocks. I started writing according to counting c blocks way & by the end of 25 mins I was done writing & dry run succesfully, there were slight minor fixes required which I did after discussing with the interviewer & a working code was there. Till now I had wasted enough time becuase I tried to explain her non_c blocks approach which she straight forwardedly rejected. In current approach, I was using seperate pointer to count continuous c blocks, which the she told, you can do it with 1 pointer also, which I agreed then the she wanted me to write that 1 pointer approach also, where I messed up at last index, which she pointed out. I fixed it but knew that my interivew has been doomed.
At last the she asked me if I have any questions? In her intro she had mentioned that she moved from Company A to Google 1 year back. So just casually I asked (just for the sake of asking) since you moved from Company A to Google what's the cultural difference you are experiencing? She straight away told I am not representing company A here in somewhat rude manner I represent Google (I wasn't even asking about company A), then I got disinterested. She had tons of ego in her statements. Just because someone is sitting at other side of the table doesn't entitle them to carry this attitude.
At last, I would say there can be multiple ways of solving a problem I didn't expect even Google interviewers are like this, that if they have some type of solution in their mind they want us exactly to write like that. I have cracked & worked at multiple top non-FAANG companies but this type of interviewer I have never faced. Even now when I am interviewing at all the decent companies, interviewers are really supportive in the conversation. I had put my heart & soul into the preparation from last 3 months for Google but this experience really hurted my preparation grind.