Google L2 Interview
Anonymous User
1824

Google Interview Experience

Location - Bangalore. Postion - SE, L2 Exp - 3 Yrs
I got a call from a recruiter. During our conversation, she asked me some general questions and inquired about my experience with coding platforms like LeetCode. After our discussion, she scheduled an interview for me to take place a month later. This interview turned out to be a knockout round; if I didn’t pass it, I would be immediately eliminated from the interview process.

Coding Question
During the interview, I was presented with the following coding question:

Problem Statement:
You are given a string containing n uppercase letters arranged in alphabetical order. Your task is to find the most frequently occurring letter.
Input:
"AAAABCC"
Output:
"A"
I initially solved this problem using a hashmap, achieving a time complexity of O(n) and a space complexity of O(26), which simplifies to O(1) since 26 is a constant.
A Funny Moment
Interestingly, while I was explaining my thought process to the interviewer, by mistake I confused him! 😅 As a result, he forgot to remind me to aim for a more efficient solution. At last 1 min after discussing everything he recalled that it can be solved more efficiently. We had a great laugh at it. As he forget and also I talk a lot.

The problem can actually be solved with a time complexity of O(log n) and a space complexity of O(1).

After 2 days I got call. That I got "Hire" remark. But then things got silent. Again after 3 months I got the call from same recruiter. She told you have already cleared the round. She will be scheduling another 3 round. She told I need 2 hire remark atleat to go to the behaviour round.

Round 1 - I was tasked with finding the sum of all nodes in a binary tree. I managed to arrive at a correct solution, but the interviewer was looking for a different approach.

function sumOfNodes(root){
	let sum=0;
	function dfs(node){
		if(!node) return 0;
		sum+=node.val;
		dfs(node.left);
		dfs(bode.right);
	}
	dfs(root)
	return sum
}

// he wanted the solution this way (I mean he didnt wanted extra function) I struggled with this requirement and had to seek a little help - 
function sumOfNodes(root){
	if(!root) return 0
	let sum=0;
	sum+=node.val;
	sum+=sumOfNodes(root.left)
	sum+=sumOfNodes(root.right)
	return sum;
}

2nd question was given a rectangle screen you are on (0,0) coordinate. Find the perimeter of the screen. Time was less we discussed about this question. The solution was to iterate until you reach to the last x coordinate. and then do the same iterate until you reach to the end of y coordinate. You are having lenght and breadth calculate it.

Round 2 - given a string of characters and a specified horizontal page width, I needed to determine how many lines the string would occupy. This problem was straightforward, and I solved it on my first attempt.
However, the interviewer then modified the problem statement slightly. Now, I had to maintain spaces in the output. For example:

Input: String: "hello, how are you doing today?"  Width: 6
Output - 6
Explanation-hello,
how
are
you
doing
today

Round 3 - Given a integer (too big to fit into memory) as strings, add them and return their result.
I was not able to solve it.

Result of these rounds -
Round 1 -"Lean No Hire"
Round 2 -"Strong Hire"
Round 3 - "No Hire"

Preparation strategy (That I followed and is not recommended)
I struggled with DSA in college and only passed my exams. As a frontend developer, my knowledge was limited to basic concepts, primarily arrays.
To prepare for my Google interview, I started with arrays and progressed to binary search, two pointers, and hashmaps. Thats it nothing else. Surprisingly, I passed the knockout round, which motivated me to learn more.
But till my third round, I had covered topics like binary trees, DFS, backtracking, and BFS. I could handle easy to medium-level questions but struggled with hard ones. However, I found dynamic programming and priority queues challenging. I could handle easy to medium-level questions but struggled with hard ones (So I didnt touched it at all).
In the final five days before the interview, I focused on solving problems mentally or on paper. If I got stuck, I watched YouTube videos at double speed to quickly grasp concepts before moving on. I prioritized understanding strategies over typing out every solution.

PS: I received an email from a Google recruiter yesterday again for a fresh round, and my interview is scheduled! I'm looking for someone to help me with mock interviews, and I'm happy to reciprocate by conducting mock interviews for others as well.

Comments (10)