Recent Interview Questions
- 2of 2 votes
AnswersWrite a code to test whether string s2 is obtained by rotating the string s1 by 2 places.
- Surekhag28 July 26, 2014 in India for Kindle
e.g S1="amazon" S2="azonam" return true
S1="quality" S2="lityqua" return false| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Coding - 0of 0 votes
AnswersSuppose you have a million integer numbers.
- l33t June 14, 2014 in United States for Hangouts
Return all possible values of a,b and c such that
a+b+c<=d.
d will be provided to you.
ex: if the numbers are 1,2,3,4,5,6,7
and d=7
[1,2,3]
[1,2,4]
[1,2,3] will be same as [1,3,2] and [3,2,1]...
follow up:
Return all such parts that satisfy the above condition if d is not provided.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 4of 4 votes
AnswersWe have 25 horses and we need to find top 5 fastest horses irrespective of order, in a race only 5 horse can run. how many min races required to know top 5 horses...out of top 5 ordering not matter...u not need to tell which is fastest which is at second position.....
- Kavita June 03, 2014 in India| Report Duplicate | Flag | PURGE
Samsung Intern - 0of 0 votes
AnswersGiven a sorted array with duplicates and a number, find the range in the
- JobSeeker April 09, 2014 in United States
form of (startIndex, endIndex) of that number. For example,
find_range({0 2 3 3 3 10 10}, 3) should return (2,4).
find_range({0 2 3 3 3 10 10}, 6) should return (-1,-1).
The array and the number of duplicates can be large.| Report Duplicate | Flag | PURGE
Linkedin Software Engineer in Test - 0of 2 votes
AnswersWrite a function return an integer that satisfies the following conditions:
- Obiwana March 10, 2014 in United States
1) positive integer
2) no repeated digits, eg., 123 (valid), 122 (invalid)
3) incremental digit sequence, eg., 1234 (valid) 1243(invalid)
4) the returned integer MUST be the smallest one that greater than the input. eg., input=987, return=1023
function signature could be like this:
String nextInteger(String input)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersShopkeeper want sells in the packs of 20,9 and 6. Given an n, you need to find whether its possible to buy the items or not.For example n=21, you can buy 2 packs of 6 and one pack of 9(2*6 + 9)
- prince February 17, 2014 in India
Output 1 if possible and 0 if not
Test cases:
1) n=47 ==> possible, output = 1
2) n=7 ===> not possible, output = 0| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - -1of 1 vote
Answersalgorithm to reverse a singly linked list using one pointer without any additional datastructures
- abhirpnk October 31, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Applications Developer Algorithm - 3of 3 votes
AnswersGiven an array, with positive and negative integers, arrange it in such a way that, positive numbers occupy even positions and negative numbers occupy odd position. All the remaining extra positive or negative integers should be stored at the end of the array. Remember, the elements of the array should remain in the same order.
- technical_123 August 11, 2013 in India
EG: Input array {1,-2,3,-4,-5,-6,-7,8,9,4,10,11,12}
output array {1,-2,3,-4,8,-5,9,-6,4,-7,10,11,12}| Report Duplicate | Flag | PURGE
Amazon Software Analyst - 0of 0 votes
AnswersA stirng is represented using a linked list how will you find if it the string is palindrom.
- rawat011 May 31, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test SDE1 Algorithm - 2of 2 votes
AnswersGiven an array of values, design and code an algorithm that returns whether there are two duplicates within k indices of each other? k indices and within plus or minus l (value) of each other? Do all, even the latter, in O(n) running time and O(k) space.
- fbrubacher May 19, 2013 in United States for Engineer| Report Duplicate | Flag | PURGE
Palantir Technology Software Engineer / Developer Algorithm - 1of 7 votes
AnswersProvide a datastructure that can perform :
- Nascent February 21, 2013 in India
1. insert
2. delete
3. find min
4,. find max
5. delete min
6. delete max
all in O(1) time.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersGiven a list of n gas station of form P(D,X) where D is the distance from this station to next station and X is the amount of petrol available at this station, identify the starting station from where you can complete journey to each station in order from 1.....N. You can only go in one direction i.e from P(i) to P(i+1)
- ravigupt January 26, 2013 in India
EDIT: I forgot to mention that travelling distance K consumes K units of gas.
EDIT2: I proposed an O(n^2) solution, then interviewer asked me if I can do better.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind the nodes at d distance from a certain node in a Binary Tree
- popoff January 02, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersU have a number, don't know how long it is, do not know how many digits, don't know when number ends, do not know which is the last number. There is a function to increment the number by 1, but function can take only stream of digits and not the complete number e.g if you have 878999 as a number, you could input this number into the function only as single digit e.g 8,7,8,9,9,9. The output should be the whole number incremented by 1 i.e 879000, remember only single digits you can send to function as input. You can use any data structure, but need to tell why you are using that particular data structure. No need to worry about Time complexity.
- algoram November 29, 2012 in United States for Site Reliability Engineering Team
Kindly, suggest how to approach this problem ?| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersA file contains a billion integers, try to find any one integer that is not in the file.
- Steve October 05, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersGiven an array of integers. Print a pair whose sum is closest to zero?
- veeru September 07, 2012 in India for Kindle Device
Eg:
Input: arr = {2 5 8 -7 2,9}
Output: => 8, -7| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
AnswersYou have to count how many binary strings are possible of length "K".
- naveenrai8 August 10, 2012 in India
Constraint: Every 0 has a 1 in its immediate left.
111011 <-- valid
0111 <--- invalid
111100 <-- invalid| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite a function that would return the 5th element from the tail (or end) of a singly linked list of integers, in one pass, and then provide a set of test cases against that function (please do not use any list manipulation functions that you do not implement yourself).
- tani August 08, 2012| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Coding - 0of 0 votes
AnswersCreate a number pool 1...infinity which has 2 methods..
- amzngoogaapl August 03, 2012 in United States
CheckIn(someNumber) and checkout()
Checkout should give the min number checked in.
Checkin should add to numberPool if number doesnt exist.
Intially all numbers 1..infinity are available.
eg:
1. checkout() gives 1
2. checkout() gives 2
3. Checkin(1)
4. checkout() gives 1 now.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a pointer to the root of a binary tree , check whether the tree is
- cobra July 19, 2012 in India
balanced or not.| Report Duplicate | Flag | PURGE
Microsoft Data Structures - 1of 1 vote
AnswersFind all unique pairs of element in an array that sum to S. For ex. If array = {2,4,6,4,6} and S = 8 then answer is {(2,6), (4,4)}
- irraju July 12, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Site Reliability Engineer Algorithm - 0of 0 votes
AnswersWrite a function that prints pairs for target sum.
- bobbysanders007 July 01, 2012 in United States
e.g.
array : 1 2 3 4 5 target: 6
pairs: (1,5) and (2,4)
void printPairs (int *a[], int target)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a set of numbers from 1 to n^2, generate subsets consisting of n numbers such that each subset has one and only one matching number from any other subset
- geeksavy May 16, 2012 in India
The max number of sub-sets is n squared + n
An example is as follows:
n = 3
n squared set = 1, 2, 3, 4, 5, 6, 7, 8, 9
sub-set 1 = 1, 2, 3
sub-set 2 = 1, 4, 7
sub-set 3 = 1, 5, 9
sub-set 4 = 1, 6, 8
sub-set 5 = 2, 5, 8
sub-set 6 = 2, 4, 9
sub-set 7 = 2, 6, 7
sub-set 8 = 3, 6, 9
sub-set 9 = 3, 5, 7
sub-set 10 = 3. 4, 8
sub-set 11 = 4, 5, 6
sub-set 12 = 7, 8, 9| Report Duplicate | Flag | PURGE
Microsoft Algorithm - 0of 0 votes
AnswersAn expression consisting of operands and binary operators can be written in Reverse Polish Notation (RPN) by writing both the operands followed by the operator. For example, 3 + (4 * 5) can be written as "3 4 5 * +".
- dprediction April 02, 2012 in United States
You are given a string consisting of x's and *'s. x represents an operand and * represents a binary operator. It is easy to see that not all such strings represent valid RPN expressions. For example, the "x*x" is not a valid RPN expression, while "xx*" and "xxx**" are valid expressions. What is the minimum number of insert, delete and replace operations needed to convert the given string into a valid RPN expression?
Input: The first line contains the number of test cases T. T test cases follow. Each case contains a string consisting only of characters x and *.
Output: Output T lines, one for each test case containing the least number of operations needed.
Constraints: 1 <= T <= 100 The length of the input string will be at most 100.
Sample Input:
5
x
xx*
xxx**
*xx
xx*xx**
Sample Output:
0
0
0
2
0
Explanation:
For the first three cases, the input expression is already a valid RPN, so the answer is 0. For the fourth case, we can perform one delete, and one insert operation: xx -> xx -> xx| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer C# - 1of 1 vote
AnswersGiven the start and an ending integer as user input, generate all integers with the following property.
- lucky March 21, 2012 in United States
Example : 123 , 1+2 = 3 , valid number
121224 12+12 = 24 , valid number
1235 1+2 = 3 , 2+3 = 5 , valid number
125 1+2 <5 , invalid number| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm - 0of 0 votes
AnswersThere is a monkey which can walk around on a planar grid. The monkey can move one space at a time left, right, up or down. That is, from (x, y) the monkey can go to (x+1, y), (x-1, y), (x, y+1), and (x, y-1). Points where the sum of the digits of the absolute value of the x coordinate plus the sum of the digits of the absolute value of the y coordinate are lesser than or equal to 19 are accessible to the monkey. For example, the point (59, 79) is inaccessible because 5 + 9 + 7 + 9 = 30, which is greater than 19. Another example: the point (-5, -7) is accessible because abs(-5) + abs(-7) = 5 + 7 = 12, which is less than 19. How many points can the monkey access if it starts at (0, 0), including (0, 0) itself? There is no input for this program.
- techieZone March 18, 2012 in United States
Print out the how many points can the monkey access. (The number should be printed as an integer whole number eg. if the answer is 10 (its not !!), print out 10, not 10.0 or 10.00 etc)| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm C++ Coding Data Structures - 0of 0 votes
AnswersPredict the out put of the following code
#include<stdio.h> int g = 0; int Add(int i) { static int s=0; s =s+i; g=g+i; return s; } int main() { int s=0;int g=0,j; for(int i=1;i<=11;i++) { g=0;s=0; j = add(i); } printf("%d,%d",j,g); return 0; }
Predict the output
- soundararajanaravind March 06, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C - 0of 0 votes
AnswersGiven an n-by-n matrix of 0's and 1's where all 1's in each row come before all 0's, find the most efficient way to return the row with the maximum number of 0's.
- dbenito February 29, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Matrix - 0of 0 votes
AnswersA king is about to give a party in 24 hours. For the party they have arranged drinks which will be served through 1000 barrels. Out of jealousy , some one near to king has poisoned one of the barrels. The poison is so strong that even a drop can kill a person. But results are not immediate. A person may die from 13 to 20 hrs. Now king has a duty of finding that barrel. He has 24 hours with him. And he has unlimited prisoners on which the drinks can be tested. Find out the maximum prisoners he would need to find out that barrel.
- pankaj.r.gupta February 22, 2012 in India| Report Duplicate | Flag | PURGE
Brain Teasers