Recent Interview Questions
- 0of 0 votes
AnswersIf i type some numbers in my cell, all phone numbers which have these typed nos in any order should appear, tell data structure for this.
- Aashish June 25, 2012 in United States
eg:if i type 926 then
932678....
92678...
9777726....
should appear.
[EDIT]: It seems you have lot of confusion.
Let me clear it through another example
eg: i enter 321, then
o/p(if they r in book)
9344241..
972153....| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Data Structures - 0of 0 votes
AnswersGiven an array of positive and negative integers find the first subarray with zero sum? no 0's will be a part of the input array and handle all the edge cases
- AnkitSablok19091989 June 19, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGive an array of integers, which are in repeated format except one integer, write a function to return that integer
- Ray Sun March 29, 2012 in United States for Kindle
ex[2,2,3,3,4,4,4,5,5] = 4
[2,2,2,3,3,3,3,4,4,4] = 3| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Coding - 0of 0 votes
AnswersFind 1st non-repeating char in string ?
- ariesgirl069 March 02, 2012 in United States for MSIT| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersGiven a binary tree, every node has a int value, return the root node of subtree with the largest sum up value. Java is more preferable. Caution: the return should be a node, not a integer!
- CreepyMan February 29, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 1of 1 vote
AnswersWrite Program to find longest common contiguous intersection from 2 lists provided to the function.
- aaz February 29, 2012 in United States for Intern
Example: list1: abcrfghwetf
list2: abrfghwwetxyab
Longest common intersection here is: fghw
Need Effecient Algorithm to implement this in Java or C, not using arrays.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm C Data Structures Ideas - 0of 0 votes
AnswersYou have n strings with their lengths. You are given an add(string s1,string s2) which would concatenate the string s2 with s1 and return s3. Optimize the cost of concatenation of all these strings into one big string.
- manjunath426jc December 26, 2011 in India
Ex: 1,3,2 are the lengths of given strings.
1+3=4
4+2=6
total cost=10
Optimize this total cost?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer String Manipulation - 2of 2 votes
AnswersGiven a set of numbers [1-N] . Find the number of subsets such that the sum of numbers in the subset is a prime number.
- Anonymous November 21, 2011 in India| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersConvert an array "a1 a2 a3...an b1 b2 b3...bn c1 c2 c3...cn" to "a1b1c1 a2b2c2...anbncn", inplace.
- max October 12, 2011 in -| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a Binary Search Tree, find the 2nd maximum element.
- Anonymous July 09, 2011| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 1of 1 vote
AnswersA rooted binary tree with keys in its nodes has the binary search tree
- Rahul June 09, 2011
property (BST property) if, for every node, the keys in its left
subtree are smaller than its own key, and the keys in its right
subtree are larger than its own key. It has the heap property if, for
every node, the keys of its children are all smaller than its own key.
You are given a set of n binary tree nodes that each contain an
integer i and an integer j. No two i values are equal and no two j
values are equal. We must assemble the nodes into a single binary tree
where the i values obey the BST property and the j values obey the
heap property. If you pay attention only to the second key in each
node, the tree looks like a heap, and if you pay attention only to the
first key in each node, it looks like a binary search tree.Describe a
recursive algorithm for assembling such a tree| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Data Structures Trees and Graphs - 0of 0 votes
AnswersYou are given an array A of k values which contain int values in sorted (asec) order. Find top k values (asec) which can either be the number from the array A, or sum of any two numbers from A or sum of any three numbers from A. So, if A's values are represented as : a1,a2,...,ak , the possible numbers can be: a(i), a(i)+a(j), a(i)+a(j)+a(l) for any i,j,l < k
- mexx April 08, 2011
Ex: A[7] = {3,4,5,15,19,20,25}
output B[7] = {3,4,5,(3+4),(3+5),(4+5),(3+4+5)}| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersTwo people are travelling through flight. Both have parachute and jump anywhere randomly i.e none of them knows who has jumped where.(Assume there's a big desert and they jump at any random location). Now, both of them have a single piece of paper on which they can write instructions before jumping and that's the only way they can meet each other. What would they write on paper before jumping ?
- omkar November 02, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Brain Teasers - 0of 0 votes
AnswersFind the width of a tree pointed by head
- vinay October 25, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm C Data Structures - 0of 0 votes
AnswersGive an unsorted array find count of pairs of numbers[a,b] where a > b and b comes after a in the array.
- Software Engineer June 20, 2010
Eg. {8,3,6,10,5}
the count of such numbers is 5. i.e. (8,3), (8,6), (8,5), (6,5) and (10,5)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersThere are 7 buckets of water and an infinite number of flies. One of the the buckets is poisoned. You need to find which one is poisoned by putting the fly in it. It will take 7 days for the fly to die and and for you to know that the bucket is poisoned. Also you need to send one of the (non-poisoned) buckets to your friend in 1 week. How will you find out the poisoned bucket in least number of flies?
- anon March 11, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Brain Teasers - 0of 0 votes
Answersgiven two binary search trees, merge them in O(n) time with O(1) space
- Anonymous November 21, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven an array of integers, write a function to find the 2nd max value. Write test cases.
- Sadineni.Venkat February 28, 2009| Report Duplicate | Flag | PURGE
Apple Arrays - 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
AnswersConvert string into new string e.g. "abcD"->"cdeF" and "plxY" -> "rnzA"
- Ripul Patel October 23, 2008| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Coding - 1of 1 vote
AnswersDesign an algorithm to find whether a given string is formed by the interleaving of two given strings or not.
- Aditya December 07, 2007
s1= aabccabc
s2= dbbabc
s3= aabdbbccababcc
Given s1,s2,s3 design an efficient algorithm to find whether s3 is formed from the interleaving of s1 and s2.| Report Duplicate | Flag | PURGE
Deshaw Inc Financial Software Developer Data Structures Coding Algorithm - 1of 1 vote
AnswersYou are given an array of integers.
- Nerd March 16, 2017 in Europe
Write an algorithm that brings all nonzero elements to the left of the array, and returns the number of nonzero elements.
The algorithm should operate in place, i.e. shouldn't create a new array.
The order of the nonzero elements does not matter. The numbers that remain in the right portion of the array can be anything.
Example:
given the array [ 1, 0, 2, 0, 0, 3, 4 ],
a possible answer is [ 4, 1, 3, 2, ?, ?, ? ], 4 non-zero elements, where "?" can be any number.
Code should have good complexity and minimize the number of writes to the array.| Report Duplicate | Flag | PURGE
Facebook Solutions Engineer Coding - 0of 0 votes
AnswersSuppose you have a matrix in the form of a 2 dimensional array. Write a method to read the rows of the matrix alternatively from right to left, left to right so on and return them as a 1 dimensional array.
- MM July 15, 2016 in United States
for eg:
1 2 3
4 5 6
7 8 9
should return 1 2 3 6 5 4 7 8 9| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 2of 2 votes
AnswersGiven two arrays/Lists (choose whatever you want to) with sorted and non intersecting intervals. Merge them to get a new sorted non intersecting array/list.
- HumbleLearner February 12, 2016 in United States
Eg:
Given:
Arr1 = [3-11, 17-25, 58-73];
Arr2 = [6-18, 40-47];
Wanted:
Arr3 = [3-25, 40-47, 58-73];| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 0of 0 votes
AnswersThere are n persons and k different type of dishes. Each person has some preference for each dish. Either he likes it or not. We need to feed all people. Every person should get atleast one dish of his chioce. What is the minimum number of different type of dishes we can order?
- prashant2006ster July 28, 2015 in India
Input is n x k matrix boolean matrix.For each person a row represent his likes or not likes each row.
n = 6 k = 7
1 0 0 0 1 0 0
1 0 0 0 0 1 0
1 0 0 0 0 0 1
0 1 0 0 1 0 0
0 0 1 0 0 1 0
0 0 0 1 0 0 1
Output
3
Explanation
Take dish number 5,6,7.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm