Google inc interview experience Real time questions & tips from candidates to crack your interview

SWE Intern

Google inc
upvote
share-icon
3 rounds | 4 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 2 months
Topics: Arrays, Stings, Stacks, Queues, Linked List, Trees, Graphs, BFS, DFS, Recursion, Dynamic Programming, Backtracking.
Tip
Tip

Tip 1 : I was informed about the interview only 3 days prior to it. So, if you find yourself in a position like me, one thing I would mention is to NEVER LEARN ANY NEW TOPICS if you have less than 2 days. Brush up on the topics you already know.
Tip 2 : Practise Time and space Complexities well. Know your basics and practice as many questions as possible on LeetCode.
Tip 3 : Refer to previously asked questions in the interview of the company. Read about the interview process for the role you're applying for. Learn about the role and the company as well. 
Tip 4: If you're new to giving interviews, practice mock interviews with your friends or family.

Application process
Where: Campus
Eligibility: 6 CGPA
Resume Tip
Resume tip

Tip 1 : Keep it to one side
Tip 2 : Only add the things necessary for the role that you're applying for.
Tip 3 : Don't lie in the resume and add projects related to the role.
Tip 4 : Add any volunteering work that you did.

Interview rounds

01
Round
Hard
Online Coding Test
Duration70 minutes
Interview date7 Jul 2022
Coding problem2

2 hard questions had to be completed in 70 Minutes. we had a time window from 12 pm to 6 pm.

1. Ninja And Numbers

Moderate
25m average time
75% success
0/80
Asked in companies
Google incDeloitteCapegemini Consulting India Private Limited

Ninja has a number ‘A’ containing ‘B’ digits. ‘A’ can be represented by a string ‘S’ where ‘S[i]’ denotes the ‘ith’ digit of ‘A’. You are also given an integer ‘K’.

Ninja thinks that a number is stable if the following condition is satisfied:

For every ‘ith’ digit where (0 <= ‘i’ <= ‘B-1’) ‘S[i] = S[i%K]’. Here, ‘X%Y’ represents the modulo operations. The remainder when ‘X’ is divided by ‘Y’.

Your task is to find the smallest number which is stable and whose value is greater than or equal to ‘A’. Zero-based indexing is used everywhere.

Example :
‘B’ = 4, ‘S’ = “4321”, ‘K’ = 3.
The given number is not stable as ‘S[3]’ is not the same as ‘S[0]’ but 3%3 = 0 same as 0%3. ‘S[3] = 1’ and ‘S[0] = 4’.  But the number “4324” is stable. As, for all ‘i’, ‘S[i]’ = ‘S[i%K]’ and “4324” is also greater than the given number. It can be proved that this is the best possible answer.
Hence, the answer is “4324”.
Try solving now

2. Count with K different characters

Moderate
15m average time
85% success
0/80
Asked in companies
AmazonWalmartCIS - Cyber Infrastructure

You are given a string 'str' of lowercase alphabets and an integer 'k' .


Your task is to return the count all the possible substrings that have exactly 'k' distinct characters.


For example:

'str' = abcad and 'k' = 2. 

We can see that the substrings {ab, bc, ca, ad} are the only substrings with 2 distinct characters. 

Therefore, the answer will be 4.    
Problem approach

I first used brute force and I got TLE. So, I optimized the code using sliding windows and map and it passed all test cases.

Try solving now
02
Round
Medium
Video Call
Duration45 minutes
Interview date16 Aug 2022
Coding problem1

It was an online interview held on google meet. The interviewer shared a question in the beginning of the interview and for the next 45 minutes, we had to brainstorm approaches to solve the quesntion.

1. Buildings Projection

Moderate
15m average time
85% success
0/80
Asked in companies
Google incalibabaBritish Telecommunications

Ninja Land can be represented as a N * N grid in the XY plane. Each cell of this grid can have a building of some height.

You are given a matrix ‘GRID[][]’ of size ‘N’ * ‘N’, where ‘GRID[i][j]’ gives the height of the building at cell (i, j) in XY plane. Note, building at any cell (i, j) is represented as a cuboid that is an axis aligned with the axis ‘X’, ‘Y’, ‘Z’ and has the dimension 1 * 1 * GRID[i][j] along X, Y, Z-axis respectively.

Ninja views the projection of these buildings onto the XY, YZ, and ZX planes. A projection is like a shadow, that maps a 3-dimensional figure to a 2-dimensional plane. We are viewing the "shadow" when looking from the top, the side, and the front, in XY, YZ, ZX plane respectively.

Your task is to find and return the total area of all three projections. See the example for more clarity.

Note:
 ‘GRID[i][j]’ = 0, if there is no building at cell (i, j).
Example:
Consider the following 2*2 ‘GRID[][]’:
                [1, 2]
                [3, 4]

Its projection in XY, YZ, XZ plane is shown below -: 

alt text

Area covered in XY plane is 4, Area covered in YZ plane is 6, Area covered in ZX plane is 7, Thus the total area is 4 + 6 + 7 = 17.
Problem approach

I solved using a nested loop that had O(n^2) time complexity. After the interview, I was able to come up with a greedy approach with O(n) time complexity.

Try solving now
03
Round
Medium
Video Call
Duration45 Minutes
Interview date16 Aug 2022
Coding problem1

It was an online interview held on google meet. The interviewer shared a question in the beginning of the interview and for the next 45 minutes, we had to brainstorm approaches to solve the quesntion.

1. Closest Cost

Moderate
34m average time
67% success
0/80
Asked in company
Google inc

Ninja is given the task to create a perfect gift for the king. He has ‘N’ wraps to choose from which he can choose to wrap the gifts. He also has ‘M’ gifts from which he can choose the gifts for the king. To choose the gifts, he sets some rules:

1) He must select exactly one wrapper to wrap all the chosen gifts.
2) He can select one or more gifts or no gifts at all.
3) He has 2 copies of the same gift. So, he can take 0 or 1 or 2 copies of each gift.

He also has a number ‘X’. He decided to spend in such a way that the total cost is as close as ‘X’. If there are multiple answers, print the minimum one.

For example:

Let’s say you have two wrappers with cost [1, 2] and three gifts with cost [3, 4, 5] and ‘X’ = 7. In the first case, you select wrapper number ‘2’ and gift number ‘1’ and ‘3’, so your total cost will be 2 + 3 + 5 = 10. While in the second case, you select wrapper number ‘1’ and gift number ‘2’, so your total cost will be 1 + 4 = 5. So out of both the cases, second case is closer to ‘X’ as abs(7 - 5) = 2 and abs(7 - 10) = 3.
Problem approach

I was it to figure out that this problem can be solved using a priority queue but I wasn't sure how. After trying different methods the interviewer give me a tip on how to use the priority queue method for this and I was able to grasp the logic for solving the problem.

Try solving now

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
company logo
SWE Intern
3 rounds | 4 problems
Interviewed by Google inc
1150 views
0 comments
0 upvotes
company logo
SWE Intern
1 rounds | 2 problems
Interviewed by Google inc
1122 views
0 comments
0 upvotes
company logo
L3 Engineer
3 rounds | 4 problems
Interviewed by Google inc
1706 views
0 comments
0 upvotes
company logo
SWE Intern
3 rounds | 3 problems
Interviewed by Google inc
594 views
1 comments
0 upvotes
Companies with similar interview experiences
company logo
SWE Intern
4 rounds | 6 problems
Interviewed by Microsoft
2319 views
0 comments
0 upvotes
company logo
SWE Intern
4 rounds | 6 problems
Interviewed by Dunzo
870 views
0 comments
0 upvotes
company logo
SWE Intern
4 rounds | 5 problems
Interviewed by Microsoft
0 views
0 comments
0 upvotes