Google Interview Questions
- 0of 0 votes
AnswersGiven a set of points (x,y) on a 2D coord system, identify list of 2D coords that are of distance less than x units long.
- Bob December 16, 2008
Eg.
Let x = 1;
Given (0,0), (0,1), (1, 2), (4,6);
Return 1 -> (0,0), (0,1)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGive you an array of String,
- superffeng April 20, 2012 in United States
return number of distinct strings in that array.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersSuppose you are given a dictionary of words based on an alphabet with a fixed number of characters. Please write a method / function which will find the longest word in the dictionary such that it can be built from successively adding a single character to an existing word in the dictionary (in any location). For instance, "a" -> "at" -> "cat" -> "chat" -> "chart".
- Anon March 24, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a Binary search tree of integer values. return the count of nodes where all the nodes under that sub-tree lies between a given range [x, y]. assume there are more than 100,000 nodes
- solxget April 24, 2015 in United States| Report Duplicate | Flag | PURGE
Google SDET - 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 - 0of 0 votes
AnswersWrite an algorithm to insert a new value into a circular sorted linked list.
- Andy2000 September 04, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a series of numbers as the input, the last one as the result. Use the rest numbers to calculate the result,only +, -, *, / are allowed. The order of the input cannot be changed. If there is an equation, print it; or print "no equation". If more than one solution, any working equation is fine.
- sophia July 20, 2012 in United States
example:
input: 2, 3, 1, 4
output: 2+3-1 = 4.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersConvert a max heap to min heap.
- Shane007 October 18, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite a function to validate a SuDoKu board.
- CS June 09, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 0of 0 votes
AnswersYou are given a squared integer matrix of nxn size in which all rows and all columns
- alljunkmail000 January 06, 2013 in United States
are sorted in ascending order. The task is to check if the given matrix contains a given key.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an array of strings of 0s and 1s. X and Y are also given. Return the maximum number of elements in a subset of the array elements which will X number of zeroes and Y number of 1s when combined. For eg: if array[] = {"01", "10", "0", "110"} X=3, Y=2
- controlc September 18, 2011 in India
Answer should be 3 since first 3 strings when combined will give the required number of 0s and 1s.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven
colors = ["red", "blue", "green", "yellow"];
and a string
str = "Lorem ipsum dolor sit amet";
write a function that prints each letter of the string in different colors. ex. L is red, o is blue, r is green, e is yellow, m is red, after the space, i should be blue.
- rninja2019 May 08, 2019 in United States| Report Duplicate | Flag | PURGE
Google Front-end Software Engineer - 0of 0 votes
Answersgiven an array of sorted integers with duplicate values , sort the array so that there are only unique values left in sorted order ( do not use any additional data type , do inplace sort )
- Tester August 09, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer in Test Coding - 0of 0 votes
AnswersGiven a list, L, of size k. L contains elements between 1 and n. Also given a function RND() such that this function returns a number between 1 and INT_MAX.
- Him53 January 10, 2012 in India
Now generate number between 1 and n, using RND(), such that the element should not be there in the list L. All elements should have a uniform probability.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersA robot has to move in a grid which is in the form of a matrix. The robot can go 1) A(i,j) to A(i,j+1) or 2) A(i,j) to A(i+1,j). Find an efficient way of computing the unique number of paths from A(0,0) to A(m-1,n-1) for the grid represented by the matrix A mxn
- InterviewMeLikeNeverBefore October 21, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersGiven an array of integers where some numbers repeat 1 time, some numbers repeat 2 times and only one number repeats 3 times, how do you find the number that repeat 3 times. Using hash was not allowed
- Anonymous March 08, 2010| Report Duplicate | Flag | PURGE
Amazon Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersRandom generate a NxN matrix with only four types of element: 1,2,3,4.
- wtcupup2017 December 30, 2016 in United States
However, no column or row can have same type of element appears 3 times or above continuously (three same type of elements are connected)
ex:
valid:
1 2 1 1
3 1 4 2
1 2 4 2
3 1 2 3
invalid because the first column has element 1 appears three times and all 1s are connected to each other :
1 2 1 3
1 3 4 2
1 2 4 4
2 3 2 2| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersFlip a monochrome bitmap around its centre-line, where input is: char *bytes, int width, int height .
- kbex07 January 25, 2013 in United States
Example:
Input
0101 0110
1111 0011
Output
0110 1010
1100 1111| Report Duplicate | Flag | PURGE
Google Intern Algorithm - 0of 0 votes
Answerslet f(n, k) be the # of ways of choosing k integers without replacement from
- Anonymous July 29, 2011
n consecutive integers so that no two selected are consecutive.
a. give a recurrence for f(n, k)
b. efficient implementation of f(n, k)| Report Duplicate | Flag | PURGE
Google Algorithm - 0of 0 votes
Answersyou are given following:
- Anonymous June 21, 2011
1. An empty tank
2. Unlimited source of water.
3. Some container of certain measurments and a container of 1 litre is always given.
Your job is to fill the tank from source of water using the containers in minimum number of steps.
You cant fill the container with a small amount of water than its size (filling partially is not allowed).
Find the number of steps and print the solution.
e.g.
Tank Size: 80 litre
Containers: 1,3,5,6,25 litre
Solution:
4
5,25,25,25
Tank Size: 71 litre
Containers: 1,3,5,6,25 litre
Solution:
6
3,6,6,6,25,25| Report Duplicate | Flag | PURGE
Google Developer Program Engineer Algorithm - 0of 0 votes
AnswersYou are given a String number containing the digits of a
- ANon March 10, 2010
phone number (the number of digits, n, can be any positive integer) . To help you memorize
the number, you want to divide it into groups of contiguous digits. Each group must contain
exactly 2 or 3 digits. There are three kinds of groups:
• Excellent: A group that contains only the same digits. For example, 000 or 77.
• Good: A group of 3 digits, 2 of which are the same. For example, 030, 229 or 166.
• Usual: A group in which all the digits are distinct. For example, 123 or 90.
The quality of a group assignment is defined as
2 × (number of excellent groups) + (number of good groups)
Divide the number into groups such that the quality is maximized. Design an efficient
algorithm to return the solution that maximizes the quality.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersA matrix is "Toepliz" if each descending diagonal from left to right is constant. Given an M x N matrix write the method isToepliz to determine if a matrix is Toepliz.
- enkadi13 July 22, 2016 in United States
Example:
Input:
67892
46789
14678
01467
Output:
True| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm Arrays - 0of 0 votes
AnswersWrite a data structure to capture long datatype? That means this data structure will keep more them 1000 or million digits.
- JobHunter July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou need to implement a versioned stack, i.e. version of stack will increment after each push/pop. Apart from push/pop, implement a method print(n) which would print stack state corresponding to version 'n'. For example:
- gadhacoder September 16, 2011 in India
-> initially stack is empty.
-> Version 1: 11 is pushed
-> Version 2: 8 is pushed
-> version 3: pop. only 11 left
-> Version 4: 15 is pushed
....
And so on.
Print(n) should print state at version 'n'.
Here 1 should print 11, 2 should print 8, 11...
All methods should be as efficient as possible.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a matrix with each row and column sorted in ascending order. Find the median in the matrix
- anwing October 13, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm