Google Interview Questions
- 0of 0 votes
AnswersWrite a Code to merge N sorted array.
- MaYanK July 08, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays - 0of 0 votes
AnswersGiven two arrays A [n] and B[m], find the smallest window in A that contains all the elements of B.
- binu May 28, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays - 0of 0 votes
AnswersFind the next in order node of given node in binary tree. Write the program of same. pointer to parent node is given.
- Anonymous January 07, 2010| Report Duplicate | Flag | PURGE
Amazon Google Software Engineer / Developer Algorithm - 0of 0 votes
Answersyou are on a biz trip and travelling from one city to another. you have a stack of unsorted flight boarding passes. only departure city and destination city are on the boarding pass. how do you find the first departure city and your final destination city, write the solution in javascript.
- codebind September 06, 2015 in United States| Report Duplicate | Flag | PURGE
Google Front-end Software Engineer JavaScript - 0of 0 votes
AnswersSort the input character array based on the dictionary given.
- amnesiac February 28, 2013 in United States
For eg:, If input word is “SHEEP“, sorting will make it as “EEHPS“.
But in the dictionary, E may not be at first. As per the dictionary, if P is first, S followed and E later and finally H.
Then sorted array is “PSEEH“.| Report Duplicate | Flag | PURGE
Google Algorithm - 0of 0 votes
AnswersGiven a matrix represented as int[n][n], rotate it 90 degrees clockwise in-place. (In-place means minimal extra memory to be used, ie, don't make a new array to copy into). Rotate clockwise means top-row becomes right-column, right column becomes bottom-row etc.
- vasan.srini October 23, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 0of 0 votes
AnswersVerify if two BSTs are same, if same is defined as BSTs contain same sorted int array.
- swk November 24, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGenerate all the numbers whose factors are 2,3 and 5. How would you find nth number .
- binu May 28, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersHow would you define a data structure that stores a set of values (i.e., a value cannot appear more than one time), and implements the following functions:
- skeptical.scientist January 05, 2013 in United States
add(p)--adds the value p to the set
delete(p)--removes the value p from the set
getrandom()--returns a random value from the set (all items should be equally likely). (Assume you have access to some nice random() function.)
Need not write actual code, just sketch a structure to implement this efficiently.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 0of 0 votes
AnswersThe maximum suffix of a string is the lexicographically largest suffix of the string. The maximum
- ALgeek September 28, 2012 in India
suffix problem is to find the maximum suffix of a given string. Linear time algorithm required.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite code that would parse an expression that is similar to BASH brace expansion. Best illustrated with an example: the expression "(a,b,cy)n,m" would be parsed into an array of the following strings:
- demonix February 12, 2015
an
bn
cyn
m
You can assume that the input will always be valid.
Hint: the expression can nest. Therefore, "((a,b)o(m,n)p,b)" parses into:
aomp
aonp
bomp
bonp
b| Report Duplicate | Flag | PURGE
Google Software Engineer Intern String Manipulation - 0of 0 votes
Answershow would you implement a secondary sorting. Meaning sorting by Category A, and then sub sorting by category B?
- adam2008 February 22, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersGiven a line, adjust this line to the page width.
- jiangok2006 August 10, 2012 in United States
For example, given "Dog is cute" (length of chars is 11) and the page width is 15, adjust the line to "Dog is cute". The extra spaces should be distributed as much even as possible. Assume there is no space before the first word or after the last word.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 0of 0 votes
AnswersGiven string input1, input2, remove wherever the occurrence of input2 in input1.
- Sachin Gupta August 07, 2011
e.g:
input1: skjthshetheshetesm
input2: she
input1 will become "skjththetesm"
Give the test cases.| Report Duplicate | Flag | PURGE
Google Developer Program Engineer - 0of 0 votes
AnswersGiven a sorted array, output all triplets <a,b,c> such that a-b = c. Expected time is O(n^2). My approach using binary search took O(n^2 logn). When you attempt an approach, test your code with this example and list your outputs for verification. Thanks.
- anonymous August 04, 2011
-12, -7, -4, 0, 3, 5, 9, 10, 15, 16| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays - 0of 0 votes
AnswersThere are 8 bottles, one has poison. What's the minimum number of rats you need to find the poison bottle in time T, and how? (You get the rats you need all at once, feed them all at the same time, and poison kills them after time T.)
- Anonymous November 29, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Brain Teasers - 0of 0 votes
AnswersYou need to organize a football tournament. There are n teams given. You need to prepare a schedule for the matches so that each team plays with every other team and on the same day no team plays twice. You want to finish the tournament as early as possible.
- anonymous March 02, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given an array representing integer. Write a function which increments this integer.
- Eugene July 16, 2015 in United States
Example: input [1,2,3] (represents 123) -> output [1,2,4]| Report Duplicate | Flag | PURGE
Google Software Developer - 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 - 0of 0 votes
AnswersFind the most frequently occurring element in a BST. In this BST we can have leftnode<=rootnode<=rightnode.
- iwanna April 09, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersAlgorithm to output for a length m of a number stream, the value of the element j appearing in the stream for which freq[j]>m/2 with space complexity O(1) and time complexity O(m). Dont need to worry about the case when there are no elements with freq > m/2.
- ALgeek November 17, 2011 in India
The question in simpler terms:
In a collection of 'M' elements, some elements are repeated. Find the element which occurred at least M/2 times.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersCode for a method that takes two arrays and returns true if one array is contained in the other..
- Anonymous February 16, 2011
1,2,3,4,5
2,3
true
1,2,3,4,5
2,4
false.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 0of 0 votes
AnswersGiven:
- Anonymous October 14, 2010
A regular 8x8 chessboard
One chess piece, a knight. Knights can move in an L-shape; two moves in either horizontal or vertical direction and one in the other direction.
Difference from a normal chessboard is that the knight is allowed to make a move that takes it off the board. But once it's off the board, it cannot move anymore.
n = The maximum number of moves that the knight is allowed to make
Find:
The probability that after n moves, the knight is still on the board.
Additional question after a solution was given:
How would you test this function that you've written?| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
Answerswrite a function isAngram(String s1, String s2) ==> boolean
- sde August 16, 2010
what's the complexity? how to improve it| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersInterviewer drew an 2D graph on the board (X and Y axis). Given a set of buildings, defined by (x1,x2,height) discuss an algorithm to determine the silhouette of the buildings (line, the skyline). Buildings can overlap each other.
- bjh August 14, 2010| Report Duplicate | Flag | PURGE
Google Front-end Software Engineer 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 - 0of 0 votes
AnswersWrite a function to find the longest common prefix string amongst an array of strings
- Jumbo August 23, 2011| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersPrint triplets that sum to 0 in an integers array
- Anonymous July 30, 2011| Report Duplicate | Flag | PURGE
Google