Google Interview Questions
- 0of 0 votes
AnswersWrite a function called deepCopy that takes an object and creates a deep copy of it.
- shabgard August 13, 2015 in United States
var newObj = deepCopy(obj);
(can't use JSON, can't use prototype)| Report Duplicate | Flag | PURGE
Google Software Engineer JavaScript - 0of 0 votes
AnswersYou should transform an structure of multiple tree from machine A to machine B. It is a serialization and deserialization problem, but i failed to solve it well.
You could assume the struct is like this:struct Node{ string val; vector<Node*> sons; }
and in machine A, you will given the point to root Node, and in machine B,you should return a pointer to root Node.
- lxfuhuo July 30, 2015 in China| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven a string representing relative path write a function which normalizes this path (i.e. replaces "..").
- Eugene July 16, 2015 in United States
Example:
input: \a\b\..\foo.txt
output: \a\foo.txt| Report Duplicate | Flag | PURGE
Google Software Engineer - 4of 4 votes
AnswersGiven an unbalanced binary tree, write code to select a node at random (each node has an equal probability of being selected).
- tested.candidate July 14, 2015 in Switzerland| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
AnswersFind a duplicates in an array of length n. The values are positive integers in the range between 1 .. n-1
- tested.candidate July 14, 2015 in Switzerland| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersIn 5 minutes write a code which checks if a given number is a power of two.
- tested.candidate July 14, 2015 in Switzerland| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersCheck if two given words are anagrams of each other.
- tested.candidate July 14, 2015 in Switzerland| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 3of 3 votes
AnswersGiven two sorted arrays find the element which would be N-th in their merged and sorted combination.
- tested.candidate July 14, 2015 in Switzerland| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
AnswersGiven a BST with unique values find in a given tree a value closest to a given value X.
- tested.candidate July 14, 2015 in Poland| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersHow would you store the relations in a social network like Facebook and implement a feature where one user receives notifications when their friends like the same things as they do?
- tested.candidate July 13, 2015 in Switzerland| Report Duplicate | Flag | PURGE
Google Software Engineer System Design - -1of 1 vote
AnswersDesign the front end of Google Calendar
- tested.candidate July 13, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer System Design - 0of 0 votes
AnswersDesign YouTube view-counting feature
- tested.candidate July 13, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer System Design - 0of 0 votes
AnswerDesign Google Suggest
- tested.candidate July 13, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer System Design - -1of 1 vote
AnswersDesign Gmail backend (data storage and API)
- tested.candidate July 13, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer System Design - 7of 11 votes
AnswersThe "surpasser" of an element in an array is defined as the number of elements that are to the "right" and bigger than itself.
- carchen2015 July 10, 2015 in United States
Example:
Array:
[2, 7, 5, 5, 2, 7, 0, 8, 1]
The "surpassers" are
[5, 1, 2, 2, 2, 1, 2, 0, 0]
Question: Find the maximum surpasser of the array.
In this example, maximum surpasser = 5| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersGiven a binary tree, implement an iterator that will iterate through its elements.
- carlosgsouza July 07, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 4of 4 votes
AnswersYou are given 2 documents. We want to know how similar they are through N-Grams.
- um01 June 20, 2015 in United States
Given an input n (n = number of word in the Ngram) and two documents(strings) find the intersection of the NGrams of two document.
E.g doc1 = 'This is a dog'
doc2 = 'This is a cat'
n = 3
Ngrams for doc1 = 'This is a', 'is a dog'
Ngrams for doc2 = 'This is a', 'is a cat'
Output 'This is a'
Find a efficient way and give its complexity.| Report Duplicate | Flag | PURGE
Google Software Engineer - 2of 2 votes
Answersstd C library has pow(x, n) function - implement that function
- kumarr.arvind June 20, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 10of 12 votes
AnswersGiven a max-heap represented as an array, return the kth largest element without modifying the heap. I was asked to do it in linear time, but was told it can be done in log time.
- lilzh4ng June 10, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 2 votes
AnswersGiven a sorted array, find a way to find the # of occurrence of a number
- aj June 09, 2015 in United States
for eg: [1, 1, 2, 3, 3, 3, 4, 5]
find # of occurrence of 3 in time better than O(n)| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 4 votes
AnswersGiven a range of floats, find the range of size 1 with max num of elements
- aj June 09, 2015 in United States
for eg: [-13.7, -14.5, -12.3, -12.5, -12.9]
one possible answer: [-12.3, -13.3]| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersGiven an array and is rotated n number of times find the number where the peak happens. The array is sorted in increasing order. Follow up question: how will you rearrange them in normal sorted order.
- madhur.eng June 03, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 4 votes
Answersi18n (where 18 stands for the number of letters between the first i and the last n in the word “internationalization,”) Wiki it.
- Gcrack May 22, 2015 in United States
Generate all such possible i18n strings for any given string. for eg. "careercup"=>"c7p","ca6p","c6up","car5p","ca5up","care4p","car4up","caree3p","care3up"..till the count is 0 which means its the complete string again.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm Arrays - 2of 2 votes
AnswersGiven an bunch of airline tickets with [from, to], for example [MUC, LHR], [CDG, MUC], [SFO, SJC], [LHR, SFO], please reconstruct the itinerary in order,
- blah_blah May 18, 2015 in United States
for example: [ CDG, MUC, LHR, SFO, SJC ].
//tickets can be represented as nodes| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 26of 26 votes
AnswersIf a canoe can hold 2 kids and a max weight of 150 lbs, write a function that returns the minimum number of canoes needed, given a list of kids and their weights.
- Rando May 17, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer - 4of 4 votes
AnswersGiven a list of queries and their counts, write a function that returns one of the queries at random such that over time it returns an equal distribution based on the counts provided in the input.
- Rando May 17, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
AnswersWrite a function which, given two integers (a numerator and a denominator), print the first N digits of a rational number. For example, for 5 / 3 with N=5, the result should be "1.66666". N=2: 1.66
- Dan Shah May 13, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer - 2of 2 votes
Answers0 1 ?
- .netDecoder May 08, 2015 in United States
? wildcard for 0 or 1
"01?"
010 011
Example:
01?0?
Will produce
01000
01100
01001
01101| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 3of 5 votes
AnswersLook at the sequence below:
- amirtar May 05, 2015 in United States
1, 11, 21, 1211, 111221, 312211, ...
Write a code that receives n and returns the nth element of the sequence. If it gets 4 as input of the method it should return 1211.| Report Duplicate | Flag | PURGE
Google Software Engineer