Google Interview Questions
- -2of 6 votes
AnswersGiven a list of integers that fall within a known short but unknown range of values, how to find the median value?
- Guy January 16, 2014 in United States
Some say we could use selection algorithm. But that will take O(n/2 * n), which results in O(n^2). I don't know how it is a good solution.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersProgram an iterator for a Linked List which may include nodes which are nested within other nodes. i.e. (1)->(2)->(3(4))->((5)(6). Iterator returns 1->2->3->4->5->6
- Madan January 13, 2014 in United States| Report Duplicate | Flag | PURGE
Google SDE1 - -2of 2 votes
AnswersGiven a line length insert white space so text is uniformly displayed within the given length
- Madan January 13, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 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 - 2of 2 votes
AnswersYou are given an array, divide it into 2 equal halves such that the sum of those 2 halves are equal. (Imagine that such division is possible for the input array and array size is even)
- gulusworld1989 January 13, 2014 in United States for Android| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 5of 5 votes
AnswersGiven an integer, find the next highest and next lowest integers, with equal number of 1s in their binary representation as the original number.
- gulusworld1989 January 13, 2014 in United States for Android| Report Duplicate | Flag | PURGE
Google Intern Algorithm - -7of 7 votes
Answersi am working on project and we want to access ASCII value of string at some index But we don't want access chat at index and parse it to integer
- zarron January 12, 2014 in United States
Example:- char character = s.charAt(8);
int ASCII = (int) character;
is there any other way to do same without converting to char?? and what will be time complexity? is there any built in function in java ? i don't know how char store in memory please anyone can explain me ? and how to handle Unicode without converting to char ??
Thanks!!| Report Duplicate | Flag | PURGE
Google Computer Scientist Algorithm - 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 - -4of 6 votes
AnswersHow would you model the animal kingdom (with species and their behavior) as a class system? Java
- Guy January 08, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer System Design - -2of 4 votes
AnswersHow would you model the animal kingdom (with species and their behavior) as a class system?
- Guy January 07, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer System Design - -2of 6 votes
Answerswhat is time complexity of concatenating two int in java example :-
- zarron December 30, 2013 in United States
int a=18965;
int b=78521369741;
after concatenation i want ans in primitive integer data types like,
int c=1896578521369741;
i want to know what is the fastest way to do this and what will be the time complexity ?| Report Duplicate | Flag | PURGE
Google Computer Scientist Algorithm - 3of 5 votes
AnswersYou're given a machine (Let's say a sprinkler). The machine is controlled with a software component that has UI. The user can set different parameters in the UI. for example : 'speed' : 120 'pressure' : 30
- GeorgyBoy December 30, 2013 in Israel
Change the system so it will accept an arithmetical expression in the UI. The expression can contain constants, parameters (e.g 'speed') and operators.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Object Oriented Design - 7of 7 votes
AnswersYou need to develop the game Snake. What data structures will you use? Code your solution.
- GeorgyBoy December 30, 2013 in Israel| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Coding Java Problem Solving - 2of 4 votes
AnswersGiven a sorted array of integers, write a function that will return the number with the biggest number of repetitions.
- GeorgyBoy December 30, 2013 in Israel
(Asked to refine the solution to be more efficient)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays Coding Data Structures Problem Solving Sorting - 3of 3 votes
AnswersGiven a board made of 2 x n squares, and boards made of 2 x 1 squares, write a function that will calculate the number of possible ways to arrange the 2 x 1 boards on the 2 x n board, in a way that will fill it completely.
- GeorgyBoy December 30, 2013 in Israel
(Asked to refine the solution to be more efficient)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Coding Problem Solving - 0of 0 votes
AnswersDesign a Rubik's Cube, including backend database portion.
- asiamgenius December 27, 2013 in United States| Report Duplicate | Flag | PURGE
Google Intern System Design - 1of 1 vote
AnswersWrite a program to return list of words (from the given list of words) that can be formed from the list of given characters. This is like Scribble game. Say for example the given characters are ('a' , 'c' , 't' } and list the words are {'cat', 'act', 'ac', 'stop' , 'cac'}. The program should return only the words that can be formed from given letters. Here the output should be {'cat', 'act', 'ac'}.
- vimal.varadachari December 19, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersImplement a circular queue of integers of user-specified size using a simple array. Provide routines to initialize(), enqueue() and dequeue() the queue. Make it thread safe.
- Madan December 18, 2013 in United States| Report Duplicate | Flag | PURGE
Google SDE-2 - 2of 2 votes
AnswersWrite a function that receives three integer inputs for the lengths of the sides of a triangle and returns one of four values to determine the triangle type (1=scalene, 2=isosceles, 3=equilateral, 4=error). Generate test cases for the function assuming another developer coded the function
- Madan December 18, 2013 in United States| Report Duplicate | Flag | PURGE
Google SDE-2 - 5of 5 votes
AnswersGiven two sorted array in ascending order with same length N, calculate the first K min a[i]+b[j]. time complexty O(N).
- mario87 December 18, 2013 in United States
some misunderstood first K, to put it straight, to find the Kth min, not the first min| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 9of 9 votes
AnswersGiven a huge N*N matrix, we need to query the GCD of numbers in any given submatrix range(x1,y1,x2,y2). Design a way to preprocess the matrix to accelerate the query speed. extra space should be less than O(N^2) and the preprocess time complexity should be as litte as possible.
- mario87 December 18, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersA soda water machine,press button A can generate 300-310ml, button B can generate 400-420ml and button C can generate 500-515ml, then given a number range [min, max], tell if all the numers of water in the range can be generated.
- mario87 December 18, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - -1of 1 vote
AnswersGiven an input file, find the line with the most vowels ( Easy)
- matanvr December 17, 2013 in United States
Followup:
Given an input file and any criteria write a function that will find the best score line and return it.
(He told me the best score can be anything, min/max/(anything that can be measured) of the criteria).| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer General Questions and Comments - 0of 0 votes
AnswersGiven a amount and several denominations of coins, find all possible ways that amount can be formed? eg amount = 5, denominations = 1,2,3.
- Roxanne December 16, 2013 in United States
Ans- 5 ways
1) 1,1,1,1,1
2) 1,1,1,2 (combinations aren't counted eg 1,2,1,1 etc)
3) 1,1,3
4) 1,2,2
5) 2,3| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 3of 3 votes
AnswersQuestion: You are given a CSV file with 3 columns -- all integers:
- nicolasvin1982 December 05, 2013 in United States
id,parent,weight
10,30,1
30,0,10
20,30,2
50,40,3
40,30,4
0 is the assumed root node with weight 0
which describes a tree-like structure -- each line is a node, 'parent' refers to 'id' of another node.
Print out, for each node, the total weight of a subtree below this node (by convention, the weight of a subtree for node X includes the own weight of X).
You may assume that the input comes pre-parsed as a sequence of Node objects
(substitute the appropriate syntax for java/python/c++):
Node {
int id;
int parent;
int weight;
// ... you can add other fields right here, if necessary
}
implement the following:
public void printSubTreeWeight(List<Node> nodes) {
....}| Report Duplicate | Flag | PURGE
Google Senior Software Development Engineer - -1of 1 vote
AnswersSuppose you have N machines connected to a network.
- codingfunnyguy December 05, 2013 in United States
Now you generate a new file on one machine, and want to sync up across all machines. please design a system to accomplish this task and also analyze the error tolerance issue.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 3of 3 votes
AnswersGiven two log files, each with a billion usernames (each username appended to the log file), find the usernames existing in both documents?
- Madan December 04, 2013 in United States| Report Duplicate | Flag | PURGE
Google SDE-2 - 5of 5 votes
Answersdesign a system to return an unique ID for each request. For most of requests, the ID value should increase as time goes, the system should handle 1000 requests per second at least.
- codingfunnyguy December 04, 2013 in United States
timestamps alone is not valid since there might be multiple requests with same timestamps.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer System Design - 8of 8 votes
AnswersGiven the array of digits (0 is also allowed), what is the minimal sum of two integers that are made of the digits contained in the array.
- azil November 28, 2013 in United States
For example, array: 1 2 7 8 9. The min sum (129 + 78) should be 207| Report Duplicate | Flag | PURGE
Google Algorithm