140 Google Interview Questions
140 Google Interview Questions
140 Google Interview Questions
You have to get from point A to point B. You dont know if you can get there.
What would you do?
Imagine you have a closet full of shirts. Its very hard to find a shirt. So what
can you do to organize your shirts for easy retrieval?
Every man in a village of 100 married couples has cheated on his wife. Every
wife in the village instantly knows when a man other than her husband has
cheated, but does not know when her own husband has. The village has a law
that does not allow for adultery. Any wife who can prove that her husband is
unfaithful must kill him that very day. The women of the village would never
disobey this law. One day, the queen of the village visits and announces that at
least one husband has been unfaithful. What happens?
In a country in which people only want boys, every family continues to have
children until they have a boy. If they have a girl, they have another child. If
they have a boy, they stop. What is the proportion of boys to girls in the
country?
If the probability of observing a car in 30 minutes on a highway is 0.95, what is
the probability of observing a car in 10 minutes (assuming constant default
probability)?
If you look at a clock and the time is 3:15, what is the angle between the hour
and the minute hands? (The answer to this is not zero!)
Four people need to cross a rickety rope bridge to get back to their camp at
night. Unfortunately, they only have one flashlight and it only has enough light
left for seventeen minutes. The bridge is too dangerous to cross without a
flashlight, and its only strong enough to support two people at any given time.
Each of the campers walks at a different speed. One can cross the bridge in 1
minute, another in 2 minutes, the third in 5 minutes, and the slow poke takes
10 minutes to cross. How do the campers make it across in 17 minutes?
You are at a party with a friend and 10 people are present including you and
the friend. your friend makes you a wager that for every person you find that
has the same birthday as you, you get $1; for every person he finds that does
not have the same birthday as you, he gets $2. would you accept the wager?
How many piano tuners are there in the entire world?
You have eight balls all of the same size. 7 of them weigh the same, and one of
them weighs slightly more. How can you find the ball that is heavier by using a
balance and only two weighings?
You have five pirates, ranked from 5 to 1 in descending order. The top pirate
has the right to propose how 100 gold coins should be divided among them.
But the others get to vote on his plan, and if fewer than half agree with him, he
gets killed. How should he allocate the gold in order to maximize his share but
live to enjoy it? (Hint: One pirate ends up with 98 percent of the gold.)
You are given 2 eggs. You have access to a 100-story building. Eggs can be
very hard or very fragile means it may break if dropped from the first floor or
may not even break if dropped from 100th floor. Both eggs are identical. You
need to figure out the highest floor of a 100-story building an egg can be
dropped without breaking. The question is how many drops you need to make.
You are allowed to break 2 eggs in the process.
Describe a technical problem you had and how you solved it.
How would you design a simple search engine?
Design an evacuation plan for San Francisco.
Theres a latency problem in South Africa. Diagnose it.
What are three long term challenges facing Google?
Name three non-Google websites that you visit often and like. What do you like
about the user interface and design? Choose one of the three sites and
comment on what new feature or project you would work on. How would you
design it?
If there is only one elevator in the building, how would you change the design?
How about if there are only two elevators in the building?
How many vacuums are made per year in USA?
Google Interview Questions: Software Engineer
Why are manhole covers round?
What is the difference between a mutex and a semaphore? Which one would
you use to protect access to an increment operation?
A man pushed his car to a hotel and lost his fortune. What happened?
Explain the significance of dead beef.
Write a C program which measures the the speed of a context switch on a
UNIX/Linux system.
Given a function which produces a random integer in the range 1 to 5, write a
function which produces a random integer in the range 1 to 7.
Describe the algorithm for a depth-first graph traversal.
Design a class library for writing card games.
You need to check that your friend, Bob, has your correct phone number, but
you cannot ask him directly. You must write a the question on a card which and
give it to Eve who will take the card to Bob and return the answer to you. What
must you write on the card, besides the question, to ensure Bob can encode
the message so that Eve cannot read your phone number?
How are cookies passed in the HTTP protocol?
You are given an array [a1 To an] and we have to construct another array [b1 To
bn] where bi = a1*a2**an/ai. you are allowed to use only constant space and
the time complexity is O(n). No divisions are allowed.
How do you put a Binary Search Tree in an array in a efficient manner. Hint :: If
the node is stored at the ith position and its children are at 2i and 2i+1(I mean
level order wise)Its not the most efficient way.
How do you find out the fifth maximum element in an Binary Search Tree in
efficient manner. Note: You should not use use any extra space. i.e sorting
Binary Search Tree and storing the results in an array and listing out the fifth
element.
Given a Data Structure having first n integers and next n chars. A = i1 i2 i3
iN c1 c2 c3 cN.Write an in-place algorithm to rearrange the elements of the
array ass A = i1 c1 i2 c2 in cn
Given two sequences of items, find the items whose absolute number increases
or decreases the most when comparing one sequence with the other by
reading the sequence only once.
Given That One of the strings is very very long , and the other one could be of
various sizes. Windowing will result in O(N+M) solution but could it be better?
May be NlogM or even better?
How many lines can be drawn in a 2D plane such that they are equidistant from
3 non-collinear points?
Lets say you have to construct Google maps from scratch and guide a person
standing on Gateway of India (Mumbai) to India Gate(Delhi). How do you do the
same?
Given that you have one string of length N and M small strings of length L. How
do you efficiently find the occurrence of each small string in the larger one?
Given a binary tree, programmatically you need to prove it is a binary search
tree.
You are given a small sorted list of numbers, and a very very long sorted list of
numbers so long that it had to be put on a disk in different blocks. How would
you find those short list numbers in the bigger one?
Suppose you have given N companies, and we want to eventually merge them
into one big company. How many ways are theres to merge?
Given a file of 4 billion 32-bit integers, how to find one that appears at least
twice?
Write a program for displaying the ten most frequent words in a file such that
your program should be efficient in all complexity measures.
Design a stack. We want to push, pop, and also, retrieve the minimum element
in constant time.
Given a set of coin denominators, find the minimum number of coins to give a
certain amount of change.
Given an array, i) find the longest continuous increasing subsequence. ii) find
the longest increasing subsequence.
Suppose we have N companies, and we want to eventually merge them into
one big company. How many ways are there to merge?
Write a function to find the middle node of a single link list.
Given two binary trees, write a compare function to check if they are equal or
not. Being equal means that they have the same value and same structure.
Implement put/get methods of a fixed size cache with LRU replacement
algorithm.
You are given with three sorted arrays ( in ascending order), you are required to
find a triplet ( one element from each array) such that distance is minimum.
Distance is defined like this : If a[i], b[j] and c[k] are three elements then
distance=max(abs(a[i]-b[j]),abs(a[i]-c[k]),abs(b[j]-c[k])) Please give a solution
in O(n) time complexity
How does C++ deal with constructors and deconstructors of a class and its
child class?
Write a function that flips the bits inside a byte (either in C++ or Java). Write an
algorithm that take a list of n words, and an integer m, and retrieves the mth
most frequent word in that list.
Whats 2 to the power of 64?
Given that you have one string of length N and M small strings of length L. How
do you efficiently find the occurrence of each small string in the larger one?
How do you find out the fifth maximum element in an Binary Search Tree in
efficient manner.
Suppose we have N companies, and we want to eventually merge them into
one big company. How many ways are there to merge?
There is linked list of millions of node and you do not know the length of it.
Write a function which will return a random number from the list.
You need to check that your friend, Bob, has your correct phone number, but
you cannot ask him directly. You must write a the question on a card which and
give it to Eve who will take the card to Bob and return the answer to you. What
must you write on the card, besides the question, to ensure Bob can encode
the message so that Eve cannot read your phone number?
How long it would take to sort 1 trillion numbers? Come up with a good
estimate.
char a;
char* b;
};
What is the yearly standard deviation of a stock given the monthly standard
deviation?
How many resumes does Google receive each year for software engineering?
Anywhere in the world, where would you open up a new Google office and how
would you figure out compensation for all the employees at this new office?
What is the probability of breaking a stick into 3 pieces and forming a triangle?
Google Interview: Engineering Manager
Youre the captain of a pirate ship, and your crew gets to vote on how the gold
is divided up. If fewer than half of the pirates agree with you, you die. How do
you recommend apportioning the gold in such a way that you get a good share
of the booty, but still survive?
Google Interview: AdWords Associate
How would you work with an advertiser who was not seeing the benefits of the
AdWords relationship due to poor conversions?
How would you deal with an angry or frustrated advertisers on the phone?
Sources
http://news.ycombinator.com/item?id=266663
http://tihomir.org/crazy-questions-at-google-job-interview/
http://www.drizzle.com/~jpaint/google.html
http://www.gamedev.net/community/forums/topic.asp?topic_id=299692
http://careers.cse.sc.edu/googleinterview
http://job-interview.blogspot.com/2005/02/google-interview-productmarketing.html
http://www.theregister.co.uk/2007/01/05/google_interview_tales/
http://money.cnn.com/2007/08/29/technology/brain_teasers.biz2/index.htm
http://blogs.lessthandot.com/index.php/ITProfessionals/EthicsIT/googleinterview-questions
http://placementsindia.blogspot.com/2007/09/google-top-interviewpuzzles.html
http://linkmingle.com/user/interview_questions/google_interview_questions
http://discuss.joelonsoftware.com/default.asp?interview.11.626758.33
http://mindcipher.com/puzzle/78-clock-works
http://www.glassdoor.com
http://bluepixel.ca/blog/?p=69
http://www.businessinsider.com/my-nightmare-interviews-with-google-2009-11