Google Interview Questions
- 0of 2 votes
AnswersGiven a tree (not necessary a Binary Tree) print (draw) the tree in original structure with proper formatting.
- Rahul September 20, 2013 in India| Report Duplicate | Flag | PURGE
Google SDE-2 Algorithm Data Structures - 0of 2 votes
AnswersGiven a file of N bytes. Find a sub-string of minimal length that is not present in the file.
- Amarantine September 21, 2012 in Russia| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Bit Manipulation - 0of 2 votes
Answershttp://www.geeksforgeeks.org/find-water-in-a-glass/
- vgupta.2119 September 18, 2016 in India| Report Duplicate | Flag | PURGE
Google Software Developer - 0of 2 votes
Answersgive examples of hash functions that maps english word to byte
- adam2008 February 11, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 2 votes
AnswersGiven n number of legacy services with user data<userid, info, date>
- next_big_gig December 05, 2014 in United States
Design an API to return user data in a given date range, it should collect data from each service and merge and return the data sorted by date.| Report Duplicate | Flag | PURGE
Google Member Technical Staff System Design - 0of 2 votes
AnswersHow do you design a Maze and what kind of data structures you use for Maze. In addition, write a method to print the shorted path from start to end point.
- Guy January 18, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 0of 2 votes
AnswersFind the Lexicographic next word of the input word from a list of words
- ajay.raj April 16, 2017 in United States
Example
Words list
[Cat, dog, cow, donkey, zebra, monkey],
input
duck
output
monkey
Input
dog
output
donkey
Can you use trie to solve it?
public String findNextWord(List<String> words, String input){
}| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 2 votes
AnswersThere is a company with 250 employees. Its records contain: EmployeeID, ManagerID (which is a reference to the EmployeeID of the manager).
- tested.candidate March 22, 2015 in UK
Part 1. List directly reporting employees for a given ID
Part 2. List all (also indirectly) reporting employees to a given ID| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 2 votes
Answersgiven string of chars,find way to compress consecutive char with no ambiguity. example:daaad
- laurentr January 29, 2014 in United States
to d4*ad; 5eeeecd to 5*14*ecd| Report Duplicate | Flag | PURGE
Google - 0of 2 votes
AnswersThe final question was just how to write a connection pool (i.e, a class that returns connections to the user, and if the user is done, returns them back to the pool)
- Guy January 19, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 0of 2 votes
AnswersImplement in OOP the old cell-phones game "snake". Implement the function "MoveUp". Follow up: how would you reduce space complexity?
- adam2008 February 11, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 2 votes
AnswersNeed to implement something like pastebin wherein you paste some text, you are given an url. The url can be used anywhere to access the text.
- kenadams.awesome May 18, 2014 in India
Various problems, features and design of this architecture were discussed.| Report Duplicate | Flag | PURGE
Google SDE1 System Design - 0of 2 votes
AnswersHow would you model the animal kingdom (with species and their behavior) as a class system?
- Guy January 08, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer System Design - 0of 2 votes
Answerscount number of combinations which are not possible.
- bit32413 August 05, 2017 in United States
There are 'n' empty slots.
A slot can be filled with 'O', 'E', or 'X'
A combination is possible if
1. 'O' s are placed in odd slot , 'E' a are placed in even slots.
2. 'O' and 'E' alternate among them,
i.e (OXOE) not allowed because between O s there is no 'E'; but (OEXXO) is allowed.
some allowed combinations
OEXXX, XXOEO, OXXEX
For 3 slots, not allowed combinations are
OXX
XXO
XEX
XXX
OXO
Only those combinations are considered in which O s and E s are in their respective odd and even slots.
i.e EEXXX will never be considered because a 'E' is in odd slot
A combination isn't allowed if 'O' is not followed by 'E' or vice versa| Report Duplicate | Flag | PURGE
Google SDE-2 Algorithm - 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 - 0of 2 votes
AnswerAssume (n+1) points on a 2D space. You observe the points from (0,0) with viewing direction and viewing angle.
- Casper November 14, 2016 in United States
Given an array (xn,yn), and a viewing angle v (45 degree), find the direction that can observe max number of points.| Report Duplicate | Flag | PURGE
Google Software Engineer Intern C++ - 0of 2 votes
AnswersGiven a matrix of each element is the height of the location, the side of the matrix has a river height h, water diffuse matrix results,
- ajay.raj December 14, 2017 in United States
Follow up If there is a place where there is not drowning a person and a dog, people want to reach the dog's position without water, the river is highly uncertain,
Ask the maximum height h such that the number of steps taken by a person is less than or equal to a given k. Traverse the height h,| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 2 votes
Answers// TokenBucket
- nauld November 22, 2016 in United States
// Goal: regulate a resource of some kind (1 token = 1 unit of a resource)
//
// init(start_tokens, max_tokens, fill_rate)
// get_tokens(int tokens)
// - block until those tokens are available in the token bucket
// - if number of tokens in the bucket is less than requested number of tokens, wait
// put_tokens(int tokens)
// - block until there is space in the token bucket for those tokens.
// fill_rate: x tokens per sec are added to the token bucket
Thread communication methods allowed are listed below. No thread safe collections are allowed.
// Lock()
// - lock()
// - unlock()
// ConditionVariable()
// - wait(lock, max_time_to_wait_in_secs)
// - releases lock before sleep and then reacquires lock upon waking
// - notify(): This wakes up 1 waiter on this condition variable
// - notifyAll(): Wakes up all waiters on this condition variable| Report Duplicate | Flag | PURGE
Google SDE-3 Algorithm - 0of 0 votes
Answers49 race cars and no two have the same speed. Now give you 7 tracks with equal length to find the 25th fastest car. At least how many races are needed.(no time recorder)
- Hai.Vincent October 14, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Brain Teasers - 0of 0 votes
AnswersGiven a string and array of strings, find whether the array contains a string with one character difference from the given string. Array may contain string of different lengths.
Ex: Given stringbanana
and array is
[bana, apple, banaba, bonanza, banamf]
and the outpost should be true as banana and banaba are one character difference.
- kpraveen420 October 03, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays String Manipulation - 0of 0 votes
AnswersGiven 2n points on a circle.find the number of ways to draw n non intersecting chords.
- NaiveCoder February 19, 2012 in India| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersWrite a function that would print all positive numbers smaller than n that can be expressed as the sum of two cubes in two different ways. Bonus: calculate the complexity of that function.
- demonix February 17, 2015 in United States
For example, 1729 is one such number because 1729 = 1^3 + 12^3 = 9^3 + 10^3.| Report Duplicate | Flag | PURGE
Google Software Engineer Intern - 0of 0 votes
AnswersGenerate all the possible substrings using the characters of a given string. Write code. (The order of chars do not matter, i.e., ac <=> ca)
- P January 24, 2012 in India
i/p: abc
o/p: { a,b,c,ab,ac,bc,abc}
<Modified the language of the question, to avoid any confusions>| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given a positive integer number N. Return the minimum number K, such that N can be represented as K integer squares.
- Anonymous January 27, 2015 in Israel
Examples:
9 --> 1 (9 = 3^2)
8 --> 2 (8 = 4^2 + 4^2)
15 --> 4 (15 = 3^2 + 2^2 + 1^2 + 1^2)
First reach a solution without any assumptions, then you can improve it using this mathematical lemma: For any positive integer N, there is at least one representation of N as 4 or less squares.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an array of integers(both positive and negative) divide the array into two parts(sub-arrays) such that the difference between the sum of elements in each array is minimum????
- Anonymous December 24, 2009| Report Duplicate | Flag | PURGE
Google Development Support Engineer Algorithm - 0of 0 votes
AnswersGiven (i) a non-empty binary search tree with double values (e.g. 3.5) in each node and (ii) a key value K
- mihirk February 15, 2012 in United States
Write a method to find the closest value to K.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Coding Data Structures Java Trees and Graphs - 0of 0 votes
AnswersGiven two sorted postive integer arrays A(n) and B(n) (W.L.O.G, let's
- Googler May 03, 2010
say they are decreasingly sorted), we define a set S = {(a,b) | a \in
A
and b \in B}. Obviously there are n^2 elements in S. The value of such
a pair is defined as Val(a,b) = a + b. Now we want to get the n pairs
from S with largest values.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer