Amazon Interview Questions
- 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 - 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 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
AnswersGiven pre order traversal of a tree. It has only 2 type of nodes, N & L (non-leaf, leaf).. Also, every node either has zero or two children.
- P January 24, 2012 in India
Produce the tree.
Eg: Pre-order NNLLL
Tree;
N
/ \
N L
/ \
L L| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersThere is integer array like {1,2,4,5,6,1,2,4,3,5,7,2,1}. I want to find the possible combination of pair which sum is 4.
- amitnagar21 January 03, 2012 in India
input : {1,2,4,5,6,1,2,4,3,5,7,2,1}
output : {1,1,2}, {2,2}, {3,1}, {1,2,1}...etc which make the sum as 4| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm PHP - 0of 0 votes
AnswersLongest palindrome of the string
- Barney Stinson May 31, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersThere is an array in an external system (i.e. u cannot access the array elements directly). The system exposes 3 functions of O(1) :
- arun March 06, 2011
length() - returns the length of the array.
get(i) - returns the element at index i.
reverse(i,j) - reverses the elements in the array from index i to index j (both indexes inclusive).
Can you sort the array in the best possible way using only these 3 operations?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an array of integers where some numbers repeat 1 time, some numbers repeat 2 times and only one number repeats 3 times, how do you find the number that repeat 3 times.
- Anonymous November 07, 2009
I gave the hashmap solution. He was looking for a bitwise operator solution.| Report Duplicate | Flag | PURGE
Amazon Algorithm - 0of 0 votes
AnswersWithout using an additional linked list arrange elements such that all even numnbers are placed after odd numbers
- Vaishnavi September 15, 2009| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance Linked Lists - 1of 1 vote
AnswersYou are given 2 strings: string, strong. Find the common alphabets in two strings and print it.
- amu0dha May 04, 2017 in United States
i/p: string , strong
o/p: strng| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Quality Assurance - 1of 1 vote
AnswersFind the maximum consecutive 1's in an array of 0's and 1's.
- nidhi.prakash.410 January 23, 2017 in India
Example:
a) 00110001001110 - Output :3 [Max num of consecutive 1's is 3]
b) 1000010001 - Output :1 [Max num of consecutive 1's is 1]| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Coding - 0of 0 votes
AnswersYour are given two strings str1 and str2, you have to generate another unique string str3, which can only generated by these two string str1 and str2, no other string can generate that string str3. Some later point you have to retrieve back those two string str1 and str2 form that unique string str3.
- neelabhsingh February 20, 2015 in India for Hyderabad| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 2 votes
AnswersIn a Binary tree, every element(node's value) must contain the sum of its left and right sub-trees.
- pavi.8081 March 08, 2014 in India
Follow up question: how would you solve this if you can ONLY increment the value of a node
Eg. If a node’s value is 20 and its sub-tree sum is 10, the node’s value can’t be set to 10 because you can only increment.
How would you solve this if you can ONLY increment the value of a node
Further clarifications.
1. You can make assumption that leaf nodes retain their original value and does not change.
2. "Sum of its left and right subtrees" means sum of all nodes' values in its left subtree + sum of all nodes' values in its right subtree.
PS: I am asking this question coz I am not sure of its solution myself. Hence seeking experts' advice.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 2 votes
AnswersGiven nxn boolean matrix (0's and 1's) .
- thebiker925 September 11, 2013 in United States
Find out whether there exist a row i and column j such that
1) all elemets of row i are zero's and
2) all elements of column j are 1's and
3)(i,j)th entry of the matrix can be either 0 or 1
Find out such a i and j exist or not .
complexity :O(n)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 6of 6 votes
AnswersGiven an input array
- gowthamganguri August 30, 2013 in India
a={1,2,3,6,2,8----}
product of all numbers=p=a[0]*a[1]*---a[n-1] where n is size of array
output arrau should be b={p/a[0],p/a[1],p/a[2]-----}. you should not use division operator.Time complexity should be less than o(n2).| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - -1of 3 votes
AnswersGave a string of characters and asked them to store in a binary search tree in such a way that it can be extracted in exactly the same order
- Bevan March 03, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
Answersconstruct a BST given its preorder traversal. solution which i gave :-
- sameersaurav2904 November 29, 2012 in India
make first element of array as node of tree and then if element is less than root and if greater then on right. but i got the answer right for the given example but i am not sure if it was right. can you please suggest me a method to do it.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C - 0of 0 votes
AnswersYou have an array of size n with values ranging from 1 to n. Exactly one number is missed and one number is repeated. Find missing number and Repeated number.
- nprabhanjan October 22, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 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
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 - 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 - 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
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