Algorithm Interview Questions
- 0of 0 votes
AnswersWrite a bitmap class where we don’t have fixed size for the bitmap. Calculate the changed bits from previous instance to new instance in least iteration.
- johnsvakel November 24, 2015 in India for GFS
Real-time usage : In file systems we will scan only those parts changed from last save to new edit. At that time this bitmap should be used to scan the changed/added/removed parts.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersJavascript Code Question: Given the BST, Write the function return all the nodes that from the given node and given distance I.e: findnode(root, node1, distance)
- jsduder November 23, 2015 in United States| Report Duplicate | Flag | PURGE
Service Now Algorithm - 1of 1 vote
AnswersGoogle is conducting a contest where they display a special doodle to the user
- dp November 23, 2015 in India
submitting the billionth query of the day. Design a system to achieve this. (NOTE:
Google has thousands of servers and each query can hit a different server).
Optimise it. How will you handle server failures?| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a string regex and another string pat find whether the pattern is acceptable against given regex string.
- neer.1304 November 23, 2015 in United States
Regex string contains following characters and special characters:
1. Normal alphabets – a to z and A to Z
2. ‘$’ – all string should end with all characters preceding $
Example:
Regex :abc$ ,
Pattern: abcd(Not acceptable) , abc(acceptable), ab(Not acceptable), dhfusdhabc(acceptable) etc..
3. ‘^’ – all string should start with all characters exceeding ^
Example: Regex : ^abc
Pattern: abcd(acceptable) , abc(acceptable), ab(Not acceptable), dhfusdhabc(NOT acceptable) etc..
Regex: ^ then only pattern acceptable is null.
4. ‘.’ – any character can be mapped to dot except null
Example 1: Regex : .abc
Pattern: Zabc(acceptable) , abc(NOT acceptable), ab(Not acceptable), habc(acceptable) etc..
Example 2: Regex :a.bc
Pattern: abc(NOT acceptable) , aXbc(acceptable), ab(Not acceptable), habc(NOT acceptable) etc..
5. ‘*’-the character just preceding * can be repeated n time where (n>=0)
Example 1: Regex :abc*de
Pattern: abccccccccccde (acceptable), abcde(acceptable), abcccd(not acceptable)| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - -5of 5 votes
AnswersHello, I am moving to Brazil and I am looking for a property in São Paulo hear about Lopes, someone knows? She is good ?
- wendelenascimento November 23, 2015 in United States
http://www.lopes.com.br/| Report Duplicate | Flag | PURGE
A9 Algorithm - 0of 0 votes
AnswerGiven a list a1,a2,a3….an. Comparison between elements is given like a1>a2, a3>a5, a4>a2…..etc. Find whether there are any situations that we can sort the list in to the ascending order on the basis of comparison. Yes or No , explain the conditions
- neer.1304 November 23, 2015 in United States| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 0of 0 votes
AnswersGiven three arrays(arr1, arr2, arr3) each containing distinct positive numbers find three numbers a,b,c each from arr1, arr2, arr3 respectively such that (abs(a-b) + abs(b-c) + abs(c-a)) is minimum.
- rishab99999 November 22, 2015 in India| Report Duplicate | Flag | PURGE
Microsoft Algorithm - 0of 0 votes
AnswersGiven 2D Array of only 0s and 1s, Find the row which gives max decimal value.
- Rajarathinam Antony November 22, 2015 in India
Input: int array[3][3] = {{0,1,0,}{1,1,0},{1,0,1}};
Output : 2(second row)...decimal value is 6| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswerGiven a string of numbers separated by spaces figure out whether or not you can arrive at 42 with the numbers using only addition, subtraction, and multiplication using java or javascript
- jsduder November 21, 2015 in United States| Report Duplicate | Flag | PURGE
Service Now Software Developer Algorithm - 0of 0 votes
AnswersBest Time To Sell Stock but with 1 restriction: after you sell your stock, you cannot buy stock on next day.
- Ray November 21, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 4 votes
AnswersGiven that you have a graph with an even number of points, how do you find two points that equally subdivide the graph?
- Ray November 21, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersFind the largest substring in s1, such that all characters in the substring are present somewhere in s2
- johnsvakel November 20, 2015 in India| Report Duplicate | Flag | PURGE
unknown SDE-2 Algorithm - -1of 1 vote
AnswersDesign and implement a scalable multi-player N*N TicTacToe game.
- neer.1304 November 19, 2015 in United States| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 0of 0 votes
AnswersImplement class Queue with help of only 2 stacks.
i.e.:
- zr.roman November 19, 2015 in Russiaclass Queue<T>{ private Stack<T> _stack1; private Stack<T> _stack2; // public methods: Enqueue, Dequeue, Peek, Count // private methods, if any. }
| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm - 0of 0 votes
AnswerImplement class Stack with help of only 2 queues,
i.e.:
- zr.roman November 19, 2015 in Russiaclass Stack<T>{ private Queue<T> _queue1; private Queue<T> _queue2; // public methods: Push, Pop, Peek, Count // private methods, if any. }
| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm - 0of 0 votes
AnswersBelow is almost correct program, there is only one line code is wrong, you have to fix it.
String str contains only a and b characters. below program checks whether str contains equal number of a and b characters.
- siva.sai.2020 November 18, 2015 in Indiavoid checkBalance(string str) { char temp[MAXLEN]; int i, j; for (i = j = 0; temp[i] = str[j]; j++) if (str[j] == temp[i]) i++; else i--; if (i == 0) printf("Balanced\n"); else printf("Not Balanced\n"); }
| Report Duplicate | Flag | PURGE
SDE1 Algorithm - 4of 4 votes
AnswersYou are given two arrays of length M and N having elements in range 0-9.Your task is to create maximum number of length K from elements of these two arrays such that relative order of elements is same in the final number as in the array, they are taken from i.e. If two elements a,b are taken from array1 and and a comes before b in array1 so in the final number a should come before b (Relative order kept same) .
- Rahul Sharma November 18, 2015 in United States
Example: N=4 and M =6
Array1 = { 3 , 4 , 6,5}
Array2 ={9,1,2,5,8,3}
Suppose K = 5, then number will be {9,8,6,5,3}
You can see {9,8,3} are taken from array2 in the same order as they are in Array2. Similarly {6,5} are taken from Array1 in the same order and number 98653 is maximum possible number.| Report Duplicate | Flag | PURGE
Google Research Scientist Algorithm - 0of 0 votes
AnswersWrite a code to find out the median in an array of integers (array could have even number of elements or odd number of elements)
- Megha Maheshwari November 18, 2015 in United States
(To update some hint at the end from the interviewer : he would look for a binary tree and find out some way to balance the tree and than obtain the median)| Report Duplicate | Flag | PURGE
Amazon Algorithm - 0of 0 votes
AnswersFor a given string and dictionary, how many sentences can you make from the string, such that all the words are contained in the dictionary.
- Annonymous November 18, 2015 in United States
// eg: for given string -> "appletablet"
// "apple", "tablet"
// "applet", "able", "t"
// "apple", "table", "t"
// "app", "let", "able", "t"
// "applet", {app, let, apple, t, applet} => 3
// "thing", {"thing"} -> 1| Report Duplicate | Flag | PURGE
Uber Software Engineer / Developer Algorithm - 3of 3 votes
AnswersI had two interviews with Google
- sameer November 17, 2015 in India
first) one with US person...he asked decent question with lot of hints...experience : positive
and
then second) interview with person from India...I prepared for one month but he asked me very tough one graph/tree question...never gave single hint and based on that one question he judged my seven years of experience in Software Development (I never experienced what they say...Google looks for approach and not final answer)
Q.1 : Arrange array in wave form A1 > a2 < a3 > a4 ...
O(n.log-n) (Note: its not A1 >= A2)
Q.2 : Given Graph with Tree characteristics, find one node as root so that height of tree will be minimum| Report Duplicate | Flag | PURGE
Google SDE-2 Algorithm - 0of 0 votes
AnswersWrite a pseudocode for a function that does the following.
- Rishi November 17, 2015 in United States
Given a node in the tree datastructure, it determines whether there exists a path from the given node to a leaf node where the sum of values along the path equals the given sum.
signature :
boolean dse(Node node, int sum)
The following assumptions maybe made
1.Each node in the tree may have anywhere from zero to many children
2. the three can have any arbitray depth
3. each node the tree has a paositive integer value assigned to it.
A can have children B,C,D
B Children are E,F
C children G
D Children H,J
H Children K
J Children L, M
A= 5,B=2, C=3,D=8,E=1,F=4,G=6,H=2,J=1,K=3,L=7,M=8
Input and output should be
dse(F,4) = true
dse(F,1) = false
dse(B,6) = true
dse(B,2)= false
dse(b,7) = false
dse(A,14) = true
dse(A,22) = true
dse(A,29) = false| Report Duplicate | Flag | PURGE
Algorithm - 0of 0 votes
AnswersGiven string a and b, with b containing all distinct characters, find the longest common subsequence's
- siva.sai.2020 November 17, 2015 in India
length. Expected complexity O(nlogn).| Report Duplicate | Flag | PURGE
Uber SDE1 Algorithm Data Structures - 1of 1 vote
AnswersGiven a 4*n block, find number of different ways of filling it with 1*2 smaller blocks. Rotation of smaller blocks is allowed.
- siva.sai.2020 November 17, 2015 in India| Report Duplicate | Flag | PURGE
Uber SDE1 Algorithm Data Structures - 3of 3 votes
AnswersImagine a man reading a book.
- zr.roman November 16, 2015 in Russia
He can perform only 2 possible actions of reading:
1) read a page in a minute (careful reading),
2) read two pages in a minute (look through).
Nothing else is permitted.
Calculate the number of all possible combinations of book reading ways with given number of pages.
Example: given 3 pages.
Answer is 3 combinations, as follows:
1st: Careful reading (1) - careful reading (1) - careful reading (1),
2nd: Careful reading (1) - look through (2),
3rd: Look through (2) - careful reading (1).| Report Duplicate | Flag | PURGE
SDE-2 Algorithm - 0of 0 votes
AnswersGiven an array of integers of unknown size, how to reverse the order of the positive integers?
- ur2cdanger November 16, 2015 in United States
Ex [4 3 8 9 -2 6 10 13 -1 2 3 .. ] =>
[ 9 8 3 4 -2 13 10 6 -1 3 2]| Report Duplicate | Flag | PURGE
unknown Software Engineer Algorithm - 1of 1 vote
AnswersGiven-an-array-of-length-n-having-integers-0-to-n-1-in-unsorted-order-we-have-to-modify-this-array-such-that-the-value-at-a-n-becomes-a-a-n-for-example-if-a-0-contains-5-then-a-0-will-have-value-a-5-and-so-on-condition-is-that-this-should-take-O-n-time-complexity
- 9811633187a November 15, 2015 in India for hr| Report Duplicate | Flag | PURGE
Adobe Field Sales Algorithm - -1of 1 vote
Answershttps://www.quora.com/Given-an-array-of-length-n-having-integers-0-to-n-1-in-unsorted-order-we-have-to-modify-this-array-such-that-the-value-at-a-n-becomes-a-a-n-for-example-if-a-0-contains-5-then-a-0-will-have-value-a-5-and-so-on-condition-is-that-this-should-take-O-n-time-complexity
- 9811633187a November 15, 2015 in India for hr| Report Duplicate | Flag | PURGE
Adobe Field Sales Algorithm - 0of 0 votes
AnswersConsider a setup where a program is continuously receiving floats as inputs (a stream of numbers). Write a method that at any given time returns a moving average. That is the average of the last K numbers received. If the method is called before the program has received K numbers, simply return the average of however many numbers have been received thus far.
- Ray November 15, 2015| Report Duplicate | Flag | PURGE
Google Jr. Software Engineer Algorithm - 0of 0 votes
AnswersGiven an active stream of sorted arrays, how would you merge them efficiently?
- Ray November 14, 2015 in Canada| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm