Google Interview Questions
- 1of 3 votes
Answersgiven a list of points in a rectangular coordinate system, seeking any two points, such that all the remaining points will be in only one side of the line.
- ajay.raj January 15, 2018 in United States| Report Duplicate | Flag | PURGE
Google Java Developer - 1of 3 votes
AnswersDesign a two player battleship game to be played over internet
- ravik June 16, 2014 in United States| Report Duplicate | Flag | PURGE
Google - 1of 3 votes
Answers - missing July 07, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Arrays - 1of 3 votes
AnswersFind the minimum of every sub-array of size k in an array of size n.
- vgupta.2119 September 18, 2016 in India
O(n) solution required.| Report Duplicate | Flag | PURGE
Google Software Developer - 1of 3 votes
AnswersImplement a vector-like data structure from scratch.
- Victor November 21, 2014 in Brazil
This question was to be done in C or C++.
Discussion topics:
1. Dealing with out of bounds accesses.
2. What happens when you need to increase the vector's size?
3. How many copies does the structure perform to insert n elements? That is, n calls to vector.push_back| Report Duplicate | Flag | PURGE
Google Software Engineer Intern Data Structures - 1of 3 votes
AnswersWhat is mean by non blocking thread safe? Is it different from thread safe blokcing? Code a non blocking thread safe queue in Java
- Madan January 13, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 1of 3 votes
AnswerOn google search, how to enable key word auto completion after a few letters typed.
- aonecoding February 19, 2017 in United States
Follow-up: How to rank the words if they are weighted by frequency?| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
AnswersImplement the plusplus operator when we are getting the input as integer array = { 9,9,9,9 }.output will be {1,0,0,0,0}
- JobHunter July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays C Coding Data Structures - 1of 1 vote
AnswersGiven an integer array, sort the integer array such that the concatenated integer of the result array is max. e.g. [4, 94, 9, 14, 1] will be sorted to [9,94,4,14,1] where the result integer is 9944141
- Anonymous February 18, 2011| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays - 1of 1 vote
AnswersConsider a series in which 8 teams are participating. each team plays twice with all other teams. 4 of them will go to the semi final.How many matches should a team win, so that it will ensure that it will go to semi finals.?
- putta.sreenivas May 11, 2011| Report Duplicate | Flag | PURGE
Amazon Google Developer Program Engineer Software Engineer / Developer Algorithm Brain Teasers - 1of 1 vote
AnswersString getSentence(String text, Set<String> dictionary);
- Vincent October 29, 2012 in United States
// text is a string without spaces, you need to insert spaces into text, so each word seperated by the space in the resulting string exists in the dictionary, return the resulting string
// running time has to be at least as good as O(n)
// getSentence("iamastudentfromwaterloo", {"from, "waterloo", "hi", "am", "yes", "i", "a", "student"}) -> "i am a student from waterloo"| Report Duplicate | Flag | PURGE
Twitter Google Software Engineer / Developer Software Engineer in Test Algorithm - 1of 1 vote
AnswersGiven preorder traversal array of a BST, recontruct the BST.
- jiangok2006 July 26, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 1of 1 vote
Answers1. A
- amklo December 30, 2010
2. Ctrl+A
3. Ctrl+C
4. Ctrl+V
If you can only press the keyboard for N times (with the above four keys), please write a program to produce maximum numbers of A. If possible, please also print out the sequence of keys.
So the input parameter is N (No. of keys that you can press), the output is M (No. of As that you can produce).| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven an array consisting of N Numbers.
- smarthbehl August 25, 2015 in United States
Divide it into two Equal(it is important) partitions (in size both contains N/2 elements) such that difference between sum of both partitions is minimum.
If number of elements are odd difference in partition size can be at most 1.| Report Duplicate | Flag | PURGE
Google Software Engineer - 1of 1 vote
AnswersGiven an array having positive integers, find a continous subarray which adds to a given number.
- brahmasani99 May 02, 2012 in India| Report Duplicate | Flag | PURGE
Google Algorithm - 1of 1 vote
AnswersGiven a dictionary of strings [ strings are in sorted order] you have to find the precedence of characters according to the dictionary..
- Anton April 21, 2012 in India
eat
bxy
e is ranked above b according to the dictionary.| Report Duplicate | Flag | PURGE
Google Amazon Software Engineer / Developer Algorithm Data Structures Trees and Graphs Brain Teasers - 1of 1 vote
AnswersYou are given a sorted list of distinct integers from 0 to 99, for instance [0, 1, 2, 50, 52, 75]. Your task is to produce a string that describes numbers missing from the list; in this case "3-49,51,53-74,76-99".
- Casper November 14, 2016 in United States
Examples:
[] “0-99”
[0] “1-99”
[3, 5] “0-2,4,6-99”| Report Duplicate | Flag | PURGE
Google Software Engineer Intern C++ - 1of 1 vote
AnswersGiven a string with multiple spaces write a function to in-place trim all spaces leaving a single space between words
- employee11 June 09, 2014 in Israel
e.g.
_ _ _ Hello _ _ _ World _ _ _
Hello _ World _ _ _ _ _ _ _ _ _| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersInteger Array Ques:
- cdude September 01, 2015 in United States
Given an integer array of variable length like so [9, 8, 8, 3] where each item in array could be 0 to 9, write a function that would take would interpret the array [9, 8, 8, 3] as a number 9883 and increment it by 1. The return of the function would be an integer array containing the addition like so [9,8,8,4]. No zeros in the first position like [0,1,2,3]. I initially suggested a possible solution of process to convert the integer array to String then convert to Integer or Long and then do the addition of 1 and then convert it back to integer array. That is not allowed when the interviewer change the ques. to not allow that.| Report Duplicate | Flag | PURGE
Google Android Engineer Arrays - 1of 1 vote
AnswersGiven an array of "array range", return an optimized array by deleting subarrays.
- dark_knight October 19, 2015 in United States
NOTE: Array range (2,6) represents (2,3,4,5,6)
INPUT: [(2,6),(3,5),(7,21),(20,21)]
OUTPUT: [(2,6),(7,21)]
Reason: (3,5) is a subarray of (2,6) and (20,21) is a subarray of (7,21)| Report Duplicate | Flag | PURGE
Google Software Engineer Intern Algorithm - 1of 1 vote
AnswersAn array of size n+1 has integers only from 1 to n. The integers 1 to n can be present 0 or more times in the array. Find the first repeating element in the array.
- AL March 27, 2011
Restrictions: O(n) algo required. Cannot use extra space(not even O(1)).| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays - 1of 1 vote
AnswersIf you're given a list of countries and its corresponding population, write a function that will return a random country but the higher the population of the country, the more likely it is to be picked at random.
- Curious September 05, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven an array of 2n elements of which n elements are same and the remaining n elements are all different. Write a C program to find out the value which is present n times in the array
- Jamob May 22, 2011| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a string.Find the longest substring in it such that the substring contains only 2 unique characters.Ex- aabbcbbbadef Ans-bbcbbb
- ANONU April 14, 2013 in India| Report Duplicate | Flag | PURGE
Google SDE1 - 1of 1 vote
Answersyou are given 2 arrays sorted in decreasing order of size m and n respectively.
- SA August 29, 2010
Input: a number k <= n*n and >= 1
Output: the kth largest sum(a+b) possible. where
a (any element from array 1)
b (any element from array 2)
The Brute force approach will take O(n*n). can anyone find a better logic. thnkx in advance.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersCounting the islands.
- byPaco September 15, 2015 in United States
Given a map N x N, 2-D array
0 - sea
X - land
Land is connected by 4-Neighbor connections, i.e.: above, down, left and right.
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
0000000000000000000X000000000000000
000000000000000000XXX00000000000000
000XX000000000000000000000000000000
000XXXX0000000000000000000000000000
0000000X000000000000000000000000000
00000000000000000000000000000000000
000000000000000000000X0000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
00000000000000000000000000000000000
Output of this map: 4 (totally 4 islands on the map)| Report Duplicate | Flag | PURGE
Google iOS Developer - 1of 1 vote
AnswersImagine you have a sequence of the form 0123456789101112131415... where each digit is in a position, for example the digit in the position 5 is 5, in the position 13 is 1, in the position 19 is 4, etc.
- 352905 February 04, 2013 in United States
Write a function that given a position returns the digit in that position.
(You could think that this sequence is an array where each cell only holds one digit so given an index return what digit is in that index, however you cannot really create an array since the sequence is infinite, you need a way to based on the index calculate the digit that goes there).
The function has to return a single digit.
Other examples:
index = 100, result = 5
index = 30, result = 2
index = 31, result = 0
index = 1000, result = 3| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGenerate a number is range (1,n) but not in a list (i,j)
- superffeng September 27, 2012 in United States for Site reliabilty
for example range is (1,1000), list is [2,3,5,9,199,200,344]| Report Duplicate | Flag | PURGE
Google Site Reliability Engineer Algorithm - 1of 1 vote
AnswersThere is a matrix, m x n. Several groups of people locate at some certain spots. In the following example, there are three groups and the number 4 indicates there are four people in this group. Now we want to find a meeting point in the matrix so that the cost of all groups moving to that point is the minimum. As for how to compute the cost of moving one group to another point, please see the following example.
- xiaoc10 March 11, 2012 in United States
Group1: (0, 1), 4
Group2: (1, 3), 3
Group3: (2, 0), 5
. 4 . .
. . . 3
5 . . .
If all of these three groups moving to (1, 1), the cost is: 4*((1-0)+(1-1)) + 5*((2-1)+(1-0))+3*((1-1)+(3-1))
My idea is :
Firstly, this two dimensional problem can be reduced to two one dimensional problem. In the one dimensional problem, I can prove that the best spot must be one of these groups. In this way, I can give a O(G^2) algorithm.(G is the number of group).
Use iterator's example for illustration:
{(-100,0,100),(100,0,100),(0,1,1)},(x,y,population)
for x, {(-100,100),(100,100),(0,1)}, 0 is the best.
for y, {(0,100),(0,100),(1,1)}, 0 is the best.
So it's (0, 0)
Is there any better solution for this problem.
Thanks,| Report Duplicate | Flag | PURGE
Google Algorithm - 1of 1 vote
Answersthere was a party.there was a log register in which entry and exit time of all the guests was logged.you have to tell the time at which there was maximum guest in the party.
- career.baghel September 11, 2010
input will be the entry and exit time of all the n guests [1,4] [2,5] [9,12] [5,9] [5,12]
the output will be t=5 as there was maximum 3 guest were there namly guest(starting from 1) 2,4 and 5.| Report Duplicate | Flag | PURGE
Google Developer Program Engineer