Interview Questions.

Google Interview Questions and Answers


Google Interview Questions and Answers

Google needs no creation. It is among the mightiest tech moguls, within the identical league as that of Apple and Microsoft, inside the international. As such, it’s only apparent that many experts and students aspire to work at Google, be part of the business enterprise that is gambling a important position in powering the I.T. International these days.

Now, Google is not any slouch on the subject of handpicking, the most proficient the various pool of the most deserving candidates. Hence, the hiring system for Google is a protracted, complex process that calls for a thorough technique to correctly make it via. So, permit’s first discuss it prior to moving on to discussing critical Google interview questions.

Google Interview Process

A common Google interview is performed in  phases:

Phone/Hangouts interviews: 2 rounds

Onsite interviews

Coding: 2 to 4 rounds

Design: Up to two rounds

Now, the telephone/Hangouts interviews awareness mainly on assessing a candidate for primary hassle-solving competencies and talent in records structures. In order to prepare for the latter, check out these data shape interview questions.

The cellphone/Hangouts interview spherical may additionally aim to test a candidate for character tendencies and interpersonal talents. The onsite interviews involve questions primarily based on programming (take a look at out this programming interview questions article), common sense, algorithms, and critical wondering.

Specifically, the coding onsite interview round(s) entails whiteboarding solutions to the harder information shape, algorithms, and programming issues. The much less skilled the candidate is, the greater rounds they need to face.

Based on the process profile for which you’re making use of at Google, you might be subjected to no, 2, or an in-among number of design rounds. It includes coming up with excessive-degree design architectures for real, sensible merchandise. Generally, the greater skilled a candidate is, the extra rounds they ought to face.

Top Google Interview Questions and Answers

So now that we’ve understood how the Google interview manner works, it’s time to get into the real element. Without any in addition ado, right here’s our pick of the 30+ applicable Google interview questions:

Question: A celebration goes on with n range of attendees, with best a single character who's known to every celebration attendee. This person can be present at the birthday party. However, this individual doesn’t recognize all and sundry on the party, and we are able to best ask questions like, does A understand B? How will you locate the stranger with the minimal number of questions requested? Also, in what number of methods are we able to clear up this trouble?

Answer: To remedy the trouble, we need to do not forget an array with N elements, representing all of the birthday party attendees. We also take into account a characteristic, are regarded (A, B). It will go back real if A is aware of B, in any other case fake. The problem can be solved in three methods:

Using Graphs (Similar to brute pressure search) - Model the solution the usage of graphs and initializing indegree and outdegree of every vertex as zero. If A is aware of B, then draw a directed side from A to B. Increase the in-diploma of B and outdegree of A by using 1.

Next, assemble all edges of the graph for every feasible pair. If the individual is present, then we can have a sink node with an in-diploma of N-1 and an outdegree of zero, due to the fact this character doesn’t realize every body at the birthday party.

The total time required for finding the sink node, i.E., the person could be (N), and the overall complexity of the trouble may be O(N^2).

Using Recursion - Recursion lets in us to decompose the whole trouble into a aggregate of smaller instances. Next, we remedy the problem of the smaller instance for the duration of the divide step. When going back, we’ll locate the character from the smaller instance, if gift.

During the combining step, make certain (take a look at) whether or not the individual is thought to everybody and she doesn’t know every person. The recurrence of the recursive decomposition might be T(N) = O(N2).

Using Stack - Based at the elimination method, we have the following observations:

If A knows B, then A isn't always the individual at the same time as B is probably. Thus, discard A.

If A doesn’t know B, then B isn't the person while A might be. So, discard B.

Repeat those  aforementioned steps until left with most effective one person.

Ensure that the ultimate individual is the character we're looking for.

For ensuring the last person is the only we're searching out we are able to use a stack as follows:

Step 1 - Push all of the birthday party attendees right into a stack.

Step 2 - Pop off  people from the stack. Based at the return fame of the AreKnown(A, B) feature, discard considered one of them and push the closing person on the stack.

Step 3 - Continue repeating Step 2 until simplest one character remains within the stack.

Step 4 - Check that the closing person doesn’t recognize every other birthday celebration attendee.

The Areknown(A, B) characteristic might be referred to as three(N-1) instances, furnished the character is present at the celebration.

Question: Manhole covers are spherical. Would it's ok in the event that they were of a few different shape, say rectangle or rectangular?

Answer: No. Manhole covers should be round to avoid them falling within the manholes. Only a round shaped manhole cover gained’t fall via the manhole. If it have been of some other form say rectangle or rectangular, then the manhole cowl can without difficulty fall into the manhole.

Question: Which of the subsequent sets doesn’t belong to the series:

[a, b, c, d]

[a, f, b, g]

[h, i, a, b]

[j, k, l, m]

Answer: The [j, k, l, m] doesn’t belong to the collection. The three final sets are a part of the series because all of them have the [a, b] subset in not unusual.

Question: What is DEADBEEF?

Answer: DEADBEEF corresponds to the hexadecimal illustration of the 32-bit wide variety, 3735928559. It become used as a magic debug cost for the duration of the assembly/mainframe instances. The DEADBEEF makes it easy to perceive even as locating and staining specific reminiscence in pages of hex dumps.

Question: Explain the 2 sum trouble. In how many approaches are we able to resolve it?

Answer: The  sum hassle is a version of the subset sum hassle. The problem entails finding all of the pairs of  integers from an unsorted array that provides up to offer a sum S.

For instance, if the unsorted array is [22, 24, 36, -3, 5, -17, 14] and the sum (S) is nineteen, then this system have to go back [22, -3], [36, -17], [5, 14].

Solution 1 (Normal): The simple strategy to this hassle is to loop via the complete array after which loop once more through the array, but this time looking for a couple that totals to the sum S. The general going for walks time for this answer can be O(N^2).

Solution 2 (Faster): This method makes use of hash tables. While passing via every element of the array, the technique assessments whether S - the cutting-edge detail exists within the hash desk or now not. Hence, we want to loop through the array simplest as soon as. So, the going for walks time for this answer is O(N).

Question: Explain the algorithm for finding the energy set of a given set.

Answer: The energy set of a given set is a set that contains all the viable combos of the elements, i.E., all of the subsets of a given set, and an empty set and the given set itself. For example, if S = [0, 1, 2, 3] is the given set, then its energy set may be:

P[S] = [[], [0], [1], [2], [3], [0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3], [0, 1, 2, 3]].

Algorithm for finding the electricity set of a given set - For a hard and fast with N factors, the overall subsets can be 2N. Therefore, the algorithm for locating the power set of a given set carries the following steps:

Step 1: Loop from 0 to 2N.

Step 2: For each number, get the binary illustration. For example, four is represented as 0100 in binary.

Step 3: Use the binary illustration to test whether or not to include a range of from the set or now not, e.G., 0100 = [exclude, include, exclude, exclude]

Question: Is it possible that 5 minus two equals four? If yes, how?

Answer: Yes, if we get rid of two alphabets, i.E., f and e from five, we get iv. It is the Roman numeral representing four.

Question: Suppose you've got an enter string 1??Zero, wherein ? Is a wildcard. Explain the algorithm to locate all possible mixtures of the string.

Answer: The input string is 1??Zero. Now, the primary and the final quantity can be constant. The center  are wildcards, which means that they may be both zero or 1.

Algorithm (popular) for locating all the possible combinations of the given string:

Step 1: Start through calling the characteristic with the string and an empty set (in which we will push 0s and 1s).

Step 2: Once the control reaches a? Make a duplicate of every string set, and upload zero for half and 1 for the alternative half of.

Step three: Continue recursively calling the function with a smaller string until the string runs empty.

For the 1??0 Input string, the set of rules works like this:

Initial set = [] (The empty set called in Step 1)

1st individual = 1, so set = [1]

2nd character = ?, so a copy of each string set will be made i.E. [1], [1]. Next, zero is delivered to at least one half of of the sets and 1 to the other 1/2. Hence, the set = [1, 0], [1, 1]

3rd individual = ?, so over again a duplicate of each string set can be made i.E. [1,0], [1,0], [1, 1], [1,1]. Next, 0 is added to half of of the string units and 1 to the alternative closing half of. Hence, the set = [1, 0, 0], [1, 1, 0], [1, 0, 1], [1, 1, 1]

4th individual = zero, so the final set is [1, 0, 0, 0], [1,0, 1, 0], [1, 1, 0, 0], [1, 1, 1, 0].

Question: How might you provide an explanation for programming and programming languages to a 10-12 months vintage?

Answer: Programming allows us to train computer systems to do specific things. A programming language is like a language that is comprehensible via computers.

Question: Write code to go looking whether an array has a majority detail. If yes, then print it.

Answer: The following C++ software searches for the general public element in an array [10, 22, 22, 21, 22, 23, 22] and then prints it:

#include <iostream>
using namespace std; 
void findMajorityElement(int arr[], int n)
    int maxCount = 0;  
    int index = -1;
    for(int i = 0; i < n; i++) 
        int count = 0; 
        for(int j = 0; j < n; j++) 
            if(arr[i] == arr[j]) 
        if(count > maxCount) 
            maxCount = count; 
            index = i; 
    if (maxCount > n/2) 
       cout << arr[index] << endl;
        cout << "No Majority Element Exists in the Array" << endl; 
int main() 
    int arr[] = {10, 22, 22, 21, 22, 23, 22};
    int n = sizeof(arr) / sizeof(arr[0]);
    findMajorityElement(arr, n);
    return 0; 




Question: Use the mathematical operations +, -, *, and / on 3, three, 7, 7 to get 24.

Answer: Divide three with the aid of seven and then add three to it. Multiply the end result with 7 to get 24 i.E.

7 x ((3/7) + three) = 24

Question: For the given list of place coordinates, [[1, 3], [2, 5], [5, 7]], is the c language (3, 7) protected? What approximately the equal c language inside the list [[2, 3], [3, 4], [5, 6], [6, 7]]?

Answer: Point three to 7 are included in the listing [[1, 3], [2, 5], [5, 7]] because 2 to 5 and 5 to 7 are included. However, points 3 to 7 aren’t blanketed within the list [[2, 3], [3, 4], [5, 6], [6, 7]] due to the fact the space between four to five isn't always blanketed here.

Question: Suppose you've got six glasses covered up in a row with the first three packed with juice and the closing 3 empty. How will you arrange the glasses in an alternative sample, i.E., one glass with juice followed by using one empty glass through swapping best as soon as?

Answer: Let us constitute the glasses packed with juice by J and empty glasses by means of E, then we've got:


Now, we desire to have:




For the E J E J E J sample, we want to change at the least twice, i.E., update 4th with 1st and 5th with 2nd glass. Hence, it isn't the answer we searching for. To acquire the J E J E J E sample, we need handiest one change, which is changing second with 5th.

Question: In how many ways are you able to locate all the triplets in a given array of n awesome elements with a sum identical to zero?

Answer: Following are the various methods to locate all of the triplets with sum zero in a given array of distinct elements:

Approach 1 (Naive Approach): Run 3 separate loops and test one by one that the sum of the three factors is 0 or no longer. Print all of the triplets whose sum equals 0, otherwise print no longer observed.

Auxiliary Space: O(1)

Time Complexity: O(n3)

Approach 2 (Hashing): In this approach, we iterate through each detail. For every element arr[i], we want to find a pair with 0 - arr[i]. This approach entails following steps:

Run a loop from i = zero to i = n - 2

Create an empty hash desk

Run inner loop from j = i + 1 to j = n -1

If - (arr[i] + arr[j]) is gift within the hash table then print arr[i], arr[j] and -(arr[i]+arr[j])

Else insert arr[j] in the hash table

Auxiliary Space: O(n)

Time Complexity: O(n2)

Approach 3 (Sorting) - Another method that we are able to use for finding all of the triplets amongst an array of n distinct factors whose sum equal to zero is primarily based on sorting. It entails the subsequent steps:

Sort the array

Run a loop from i = 0 to i = n - 2 and initialize two index variables, l = i + 1 and r = n - 1

While (l < r):

Check whether or not the sum of arr[i], arr[l], arr[r] is 0 or now not.

In sum:

is 0, then print the triplet and do l++ and r--

is less than zero, then l++

is greater than zero, then r--

doesn’t exist inside the array, then print no longer discovered

Auxiliary Space: O(1)

Time Complexity: O(n2)

Question: How many months have 28 or 29 days?

Answer: All 365 days have 28 or 29 days.

Question: How in many instances the palms of a clock, minute, and hour palms, overlap each other in a single day, i.E., 24 hours? Explain mathematically. Also, point out the time when they'll achieve this.

Answer: For T hours:

Total laps finished by the minute hand = T

Total laps completed by the hour hand = T/12

The very first time within the day whilst the minute and hour hands overlap after 12 am, the previous may have completed one more lap than the latter. Hence, for one overlap, the time period T can be:

T = T/12 + 1                                              - (i)

Solving it for T we get,

T = (12+T)/12

12T = 12 + T

12T - T = 12

11T = 12

T = 12/11


T = (12/eleven) * 60 = sixty five, which is 1:05 am

sixty five minutes is likewise the gap among each successive overlap. Now, the second time the hour and minute hands overlap each other; the minute hand will have finished 2 greater laps than the hour hand. So, making use of the identical good judgment for N overlaps we get:

T = T/12 + N                                               - (ii)

We have 24 hours in an afternoon, i.E., T = 24. Therefore, solving (ii) will get the overall quantity the hour and minute palms will overlap one another in an afternoon:

24 = 24/12 + N

24 = 2 + N

N = 24 -2

N = 22

So, the minute and hours hand will overlap each other 22 instances a day at:

12:00 am, 01:05 am, 02:10 am, 03:15 am, 04:20 am, 05:25 am, 06:30 am, 07:35 am, 08:40 am, 09:forty five am, 10:50 am, 12:00 pm, 01:05 pm, 02:10 pm, 03:15 pm, 04:20 pm, 05:25 pm, 06:30 pm, 07:35 pm, 08:forty pm, 09:45 pm, and 10:50 pm.

Question: An aircraft crashed, ensuing in injuring every single character on the plane besides two. Is it feasible?

Answer: This is viable because the two people were married and not unmarried like others at the plane. So, additionally they got injured but not as unmarried human beings.

Question: What will be the next range within the following series: 10, 9, 60, ninety, 70, 66?

Answer: If we spell the numbers, then we study that every successive quantity has one greater alphabet than the only previous it:

10 - ten (3 alphabets)

9 - nine (4 alphabets)

60 - sixty (5 alphabets)

90 - ninety (6 alphabets)

70 - seventy (7 alphabets)

66 - sixty-six (8 alphabets)

Hence, the quantity following 66 will be a variety of with nine alphabets, like ninety one (ninety-one) or ninety two (ninety-).

Question: If the day earlier than the day gone by is three days after Saturday, what day is it these days?

Answer: Three days after Saturday is Tuesday. So, the day earlier than the day before today is Tuesday. So:

The day earlier than the day past become Wednesday, and

Yesterday was Thursday

So, nowadays is Friday.

Question: Garry is four times older than his more youthful brother James. Find out the age of Garry whilst he could be twice as vintage as James. Garry is sixteen years antique.

Answer: Garry is sixteen years old, four instances the age of his younger brother James. So, the prevailing age of James is:

16/4 = 4 years

This method that Garry is 16 - four = 12 years older than James. Now, allow us to suppose that Garry is x years old while he is two times the age of his younger brother. Let us represent the age of James at that time via y years. Now, as Garry might be two times the age of James, we get:

x = 2y                                                      -  (I)

But also,

x = 12 + y (Since Garry will always be 12 years older to James)  - (II)

x = 2y = 12 + y

2y - y = 12

y = 12

So, James can be 12 years vintage when his brother could be two times his age. Hence, the age of Garry at that point can be = 2 x 12 = 24 years.

Question: How will you get 10000 through including most effective 8?

Answer: To get 10000 best by means of including eight, we should add 8 three times, 88, and 888, i.E.:

8 + 8 + 8 + 88 + 888 = 10000

Question: Suppose you have got eight balls, out of which 7 weigh equal at the same time as the remaining one is barely heavier. How will you discover the heavier one with the aid of comparing weights best twice?

Answer: Out of the 8 balls, take 6. Now, divide them into triplets and place them on either side of a weighing device. If they're same then, the heavier ball need to be one of the closing 2 balls. Otherwise, the side that weighs heavier will have the heavier ball.

If the ball is in the final  balls then:

Simply place each of them on both aspect of the weighing gadget to locate the heavier ball.


Out of the triplets, take 2 balls and region each one among them on either facet of the weighing machine. If they weigh same, then the closing ball is the heavier one; otherwise, the heavier facet can have the heavier ball.

Question: In the series 0, 1, 1, 2, three, 4, 5, eight, thirteen, 21, which range doesn’t belong to it?

Answer: The Fibonacci collection constitute numbers which are the sum of the preceding  numbers. The variety four doesn’t belong to the collection as the final is the Fibonacci collection, i.E., zero, 1, 1, 2, three, 5, 8, thirteen, 21.

Question: A person wants to climb a staircase of N steps. On each step, there are two climbing choices; either take 1 step or 2 steps. Find out the total number of approaches to climb the staircase. What would the programming idea(s) be required to put in force a technique to the problem for locating out the various ways wherein the staircase may be climbed?

Answer: Let’s have a look at the answer of the trouble beginning from the smallest quantity of stairs, i.E., 1 up to five stairs. Let’s represent the entire quantity of solutions with S.

When N = 1, S = 1

When N = 2, S = 2 , The individual can:

Either take 1 steps two times, or

2 steps as soon as

When N = three, S = 3, The man or woman can:

Either take 1 steps three times, or

2 steps first after which 1 step, or

1 step first and a pair of steps thereafter

When N = 4, S = five, The man or woman can:

Either take 1 step 4 instances, or

2 steps  times, or

1 step first and a pair of steps then and 1 step again, or

2 steps first accompanied by means of 1 step twice, or

1 step two times and 2 steps thereafter

When N = 5, S = 8, The character can:

Either take 1 step five instances, or

2 steps twice and 1 step, or

1 step then 2 steps two times, or

1 step observed by using 2 steps and then 1 step twice, or

2 steps first observed by 1 step accompanied by means of 2 steps

2 steps first after which 1 step thrice, or

1 step three times accompanied by way of 2 steps, or

1 step two times then 2 steps after which 1 step

If we study the solutions for N = 1 to N = 5, we are able to see that the overall solutions to be had for N are equal to the total quantity of answers for N - 1 and N - 2. Let’s take a look at this:

For N = 3, S = S(3 - 1) + S(3 - 2) = S(2) + S(1) = 2 + 1 = 3

For N = 4, S = S(4 - 1) + S(4 - 2) = S(3) + S(2) = 3 +  2 = 5

For N = 5, S = S(5 - 1) + S(5 - 2) = S(4) + S(3) = 5 + 3 = 8

To discover the total answers for N, we ought to be aware of the solutions for the previous two values of N, i.E., N - 1, and N - 2. Hence, for imposing a program to discover the various viable approaches to climb a staircase with N ladders, we must use recursion.

Question: How will you are expecting the rating of a soccer suit before it starts offevolved and seems to be actual every single time?

Answer: Say zero-0 whilst the match starts offevolved. It can be authentic for each football healthy as it could be the opening circumstance of every match.

Question: What could be the next wide variety inside the collection 5, 10, 19, 32, forty nine, 70, 95?

Answer: Subtracting each preceding fee from the successive cost, we get:

10 - 5 = 5

19 - 10 = 9

32 - 19 = 13

49 - 32 = 17

70 - 49 = 21

95 - 70 = 25

We can observe that each successive distinction will increase with the aid of four. Therefore, the variety after 95 will be 29 greater than 95 i.E. Ninety five + 29 = 124.

Question: Briefly explain the distinction between coding and programming.

Answer: Coding strictly refers to writing code for imposing a way to a trouble. Programming, even though used interchangeably with coding, is a wider process that involves coding in addition to the approach for solving a particular problem and doing different important matters related to program development, consisting of checking out.

Know in element approximately Coding vs. Programming.

Question: How will you calculate the cube root of quite a number, upto 6 digits, faster than the traditional approach of mathematically calculating the dice root?

Answer: We can enforce this via the usage of desk lookups and a trick (mathematical pattern-primarily based shortcut). The set of rules for locating the dice root of some of max. 6 digits is:

Step 1 - Store the first 10 cube roots, their cubes, and the last digit of their cubes in a research desk.

Step 2 - Ignore the closing three digits of the quantity and compare the final number (at max three digits) with the cubes in the research table. Note down the dice root of the dice this is less than or equal to the first three digits.

Step 3 - Loop thru the table for the final 3 digits of the variety to get the ith index, when i = the final digit of the variety. Note down the corresponding the ultimate digit of the dice from the research table.

Step four - Combine numbers from Step 2 and Step three to get the solution.

For instance, let’s find out the cube root of 912673 using the aforementioned set of rules.

Step 1 - Generating the lookup table:

Number Cube Last digit of the cube
0 0 0
1 1 1
2 8 8
3 27 7
4 64 4
5 125 5
6 216 6
7 343 3
8 512 2
9 729 9

Step 2 - Ignoring the ultimate three digits, we get 912. Comparing it with the cube roots inside the research table, we get 729<912. So note nine.

Step 3- The last digit of the last three digits, i.E., 673, is 3. Looking for the wide variety inside the final digit of the dice column inside the research desk, we get 7.

Step 4- The cube root of 912673 is ninety seven.

Note: The range furnished to this system ought to have an excellent cube root.

Question: A casino has four gates, particularly Gate 1, Gate 2, Gate three, and Gate four. There are 3 conditions here:

Entering the on line casino on every occasion deducts $five

Exiting the on line casino every time deducts $five

Entering the casino will double the amount.

A man or woman enters the on line casino from Gate A and makes an exit through Gate B. The man or woman is going in the on line casino once more thru Gate C and is derived out from Gate D. The character is left without a cash. Find out the quantity of money the character had initially even as getting into the casino the first time.

Answer: Let us anticipate the cash that the character had even as first entering the on line casino is x. Now:

After entering via Gate A the entire amount of cash the man or woman has = 2(x - five)

Money left with the individual at the same time as exiting the casino from Gate B = 2(x - 5) - five = 2x - 15

Total amount the individual has at the same time as getting into the on line casino again from Gate C = 2(2x - 15) - five) = 4x - forty

Total money the person has at the same time as leaving the on line casino once more from Gate D = 4x - forty - 5 = 4x - forty five

Now, we recognise that the character is left and not using a money whilst exiting from Gate D. Therefore, we've got:

4x - 45 = 0

4x = 45

x = 45/4

x = 11.25

The individual had $eleven.25 while coming into the on line casino for the very first time.

Question: There is a committee of 10 participants. An antique member of the committee is now changed with a more youthful member. However, the common age for a member of the committee four years in the past is the same as that of the average member age these days. Find out how a great deal more youthful the brand new member is from the member he replaced.

Answer: Let’s make the following assumptions:

Age of the older/replaced member 4 years ago = o

Sum of the a while of the closing nine committee members 4 years in the past = x

Average age of committee participants 4 years ago = aold = (o + x)/10

Age of the more youthful member = y

Sum of the a while of the final nine contributors now = z

Average age of committee members at present = anew = (y + z)/10

As each the averages are equal i.E. Aold = anew, we get:

aold = (o + x)/10 = anew =(z + y)/10

 o + x = z + y     - (I)

Now, z is the sum of the present ages of the 9 committee individuals who are all of the equal. As every of them would be four years older now, we get:

z =  x + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4

z = x + 36

Replacing for z in equation (I), we get:

o + x = x + 36 + y

o = y + 36

Therefore, the replaced member is 36 years older than the new member.

Question: A automobile is driving at one hundred mph on a toll road. What may be the speed of each of its wheels once they contact the floor? What can be the identical whilst the automobile is touring at 120 mph?

Answer: No be counted the velocity of the automobile, the wheels could have 0 mph pace at any time even as touching the ground. This is due to the fact whilst rolling, the wheel actions in two ways:

Rotationally, around its middle, and

Horizontally, within the route of the shifting car.

At the factor of the contact, both motions of the wheels cancel out each other. This consequences in a net velocity of zero mph with recognize to the street.


These questions are most effective desirable to provide you an concept about how Google interviews are performed. That manner there's a completely narrow threat of any of those questions asked throughout your interview, specifically the ones that require important thinking. Anything, however, is viable, and you may get one or a lot of these questions or comparable ones requested all through your interview spherical.

Google holds a repute for asking brain-teasing questions. So, you ought to always be in your toes and need to count on the sudden. Remember, “if one man can do it, every other can do.” Good good fortune!