Google Interview Questions
- 3of 3 votes
Answerswe have a random list of people. each person knows his own height and the number of tall people in front of him. write a code to make the equivalent queue.
- pari February 18, 2014 in United States
for example :
input: <"Height","NumberOfTall","Name">,
<6,2,"A">,<1,4,"B">,<11,0,"C">,<5,1,"D">,<10,0,"E">,<4,0,"F">
output: "F","E","D","C","B","A" --> end of queue| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 4of 4 votes
Answersgiven an 2D matrix M, is filled either using X or O, you need to find the region which is filled by O and surrounded by X
- smit February 14, 2014 in India
and fill it with X.
example 1:
X X X X X
X X O O X
X X O O X
O X X X X
Answer :
X X X X X
X X X X X
X X X X X
O X X X X
example 2:
X X X X X
X X O O X
X X O O O
O X X X X
answer 2:
X X X X X
X X O O X
X X O O O
O X X X X| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 4 votes
AnswersGiven an array of n elements (a1,a2,..ai,...,an). You are allow to chose any index i and j, such that (i!=j) and allow to perform increment operation on ai = ai+1 and decrements operation on aj = aj - 1 infinite number of times. How many maximum number of elements you can find that have same number.
- smit February 14, 2014 in India
example 1:
1 4 1
ans: 3
example 2:
2 1
ans : 1| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 2 votes
AnswersGiven an array of n elements (a1,a2,..ai,...,an). You can allow to chose any index i and j, such that (i!=j) and allow to perform
- smit February 14, 2014 in India
increment operation on ai = ai+1 and decrement operation on aj = aj-1 infinite number of times.
How many number of elements you can find which have same numbers.
example 1:
1 4 1
ans: 3
example 2:
2 1
ans : 1| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - -7of 11 votes
AnswersGiven a circle with N defined points and a point M outside the circle, find the point that is closest to M among the set of N. O(LogN)
- Guy February 11, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -6of 6 votes
AnswersGiven a preorder traversal, create a binary search tree in optimized time
- Guy February 11, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -4of 6 votes
AnswersGiven a binary tree, how would you copy it from one machine to the other, assume you have a flash drive. I believe we should write the binary tree to file and have the other machine de-serialize it. But how should we do it?
- Guy February 10, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -11of 11 votes
Answerslargest number that an int variable can fit given a memory of certain size
- Guy February 10, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -5of 7 votes
AnswersImplement a class to create timer object in OOP
- Guy February 10, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Object Oriented Design - -9of 9 votes
AnswersWhat's the tracking algorithm of nearest location to some friends that are located in a grid region?
- Guy February 10, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -5of 7 votes
AnswersHow would you split a search query across multiple machines?
- Guy February 10, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer System Design - 1of 1 vote
Answerdef inc:
- sunshihaosd February 09, 2014 in United States
while True:
v = v + 1 //---A
set(s) // ---B
def disp:
while True:
wait(s) //---C
print v //----D
print all possible value, which is shared value. At the begin , v = 0
s is binary semophore. initial value is 0| Report Duplicate | Flag | PURGE
Google SDE1 Algorithm - -5of 7 votes
AnswersGiven a list of strings. Produce a list of the longest common suffixes. If it asks for longest common substring, then building a suffix tree should be the way to go. But how should we implement this if it is for longest common suffixes?
- Guy February 09, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven a kernal code in "0"th machine. How soon you can replicate the kernal across N machines. Now if the machines has upload and download bandwidth constraints, how can you impove the copy time.
- sjsu February 07, 2014 in United States| Report Duplicate | Flag | PURGE
Google - -6of 6 votes
AnswersIf you have data coming in rapid succession what is the best way of dealing with redundant data?
- Guy February 06, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - -7of 7 votes
AnswersHow would you use Dijkstra's algorithm to solve travel salesman problem, which is to find a shortest path from a starting node back to the starting node and visits all other node exactly once.
- Guy February 06, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -3of 5 votes
AnswersHow does trie handle scalability as opposed to hashtable? Assuming it is used for a dictionary. Sclability here should cover large size of input, running out of memory, or even running out of memory on multiple machines if distributed system is used.
- Guy February 06, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer System Design - 1of 1 vote
AnswersYou have two sorted list. Write code for returning the first k elements. K may be a large number like 10 million.
- hirajhil February 05, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Intern - 3of 3 votes
AnswersYou have a lists with integers. Find all the pairs of numbers that sum less than or equal to to a particular number k. The list contains minimum 5 Million number.
- hirajhil February 05, 2014 in United States
(I provided a n^2logn solution but they may be looking forward to having a better answer).| Report Duplicate | Flag | PURGE
Google Software Engineer Intern Algorithm - 1of 1 vote
AnswersImplement a sudoku solution verifier function. The rules for sudoku is this:
You have a 9 by 9 board. This board is divided into nine rows, nine columns, and nine 3x3 blocks. In a solved puzzle, every row, every column, and every 0 block has to contain each of the digits from 1 to 9. This is an example of a solved puzzle:
- .·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º> February 05, 2014 in United States248|395|716 571|628|349 936|741|582 ---+---+--- 682|539|174 359|174|628 714|862|953 ---+---+--- 863|417|295 195|286|437 427|953|861
| Report Duplicate | Flag | PURGE
Google Senior Software Development Engineer Algorithm - -8of 8 votes
Answerssort the array so that the odd number in front of the even number and their relative order doesn't change in Time O(n) and Space O(1). I believe quickselect can do this, but it will change the relative order of the input.
- Guy February 01, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -1of 5 votes
AnswersWhat happens during and after a query is being typed (autocomplete) in a search box whether the user is trying to go to a website or asking a question etc, and how do servers complete the request and what is the best (parallel) structure for the request to go through. DFS and how servers are located for proximity
- Guy January 30, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer System Design - -1of 5 votes
AnswersWrite code to return a random line from a file of unknown size and variable length rows
- Guy January 30, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -2of 8 votes
AnswersHow to remove duplicate lines in a large text file? I think it's easy to find duplicate lines, but how do we efficiently remove them from the file?
- Guy January 30, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Large Scale Computing - -3of 5 votes
AnswersHow would you design a chess game in OOP?
- Guy January 30, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Object Oriented Design - -3of 5 votes
AnswersGiven inputs from Google Search, you have K chunks. Each chunk is individually alphabetically ordered (apple, banana, cat) ... (*apple, *banan, *cat). You want to merge all chunks into a single list. How would you do it?
- Guy January 30, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
Answersgiven 2 Dimensional array
- xyz January 30, 2014 in United States
I/P -- String[][] input = { { "abc", "def", "gh" },
{ "f", "g" },
{ "qrt","xyz","pqr" } };
Program shd return a 2-D Array with
O/P -- { { "abcfqrt", "abcfxyz", "abcfpqr" ,abcgqrt and so on ..| Report Duplicate | Flag | PURGE
Google SDE-2 Arrays - -3of 7 votes
AnswersCount the number of positive integers less than N that does not contains digit 4.
- Guy January 30, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -11of 13 votes
AnswersIf you had a savings account with $1, at a 100% interest rate, at what year would you have 15 billion dollars? I know it's Log base 2 of 15 billion. But how did it get to log base 2? What's the formula here?
- Guy January 29, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Math & Computation - -3of 5 votes
AnswersThe setup is that we are given a series of text files which contain information regarding a code repository's commits. Each file represents a single commit and they are formatted as follows:
- Guy January 29, 2014 in United States
"
Commit #: XXX
Author: XXX
Reviewer(s): XXX, XXX, ...
File: XXX
File: XXX
...
Date: XX:XX:XX XX/XX/XXXX
"
The commit number is unique and is generated in synchronous order. There is exactly 1 unique author. There are a variable number of reviewers, delimited by commas; if there are no reviewers, that line is absent from the file. There are a variable number of edited files in the commit, each receiving its own line. The time/date is when the commit was submitted.
First design a graphical model for all of the commit data. Then describe how this model is updated when a new commit is generated. Finally, write the code segment called when a new commit is generated which edits a system that has implemented your model of the data - its input is a file name and whatever necessary data structures that are maintained by your system.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer System Design