Amazon Interview Questions
- 0of 0 votes
AnswersThere is a binary tree of size N. All nodes are numbered between 1-N(inclusive). There is a N*N integer matrix Arr[N][N], all elements are initialized to zero. So for all the nodes A and B, put Arr[A][B] = 1 if A is an ancestor of B (NOT just the immediate ancestor).
- Vin May 26, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Matrix - 0of 2 votes
Answerswrite a code to print the second largest element in a list
- Anonymous May 04, 2013 in United States
Shortest possible complexity.| Report Duplicate | Flag | PURGE
Amazon Software Engineer Intern Algorithm Data Structures - 0of 0 votes
AnswersN boys are sitting in a circle. Each of them have some apples in their hand.
- pavi.8081 April 09, 2013 in United States
You find that the total number of the apples can be divided by N.
So you want to divide the apples equally among all the boys.
But they are so lazy that each one of them only wants to give one apple to one of the neighbors at one step.
Calculate the minimal number of steps to make each boy have the same number of apples.
Input Given:
1. A number N => number of children.
2. Sequence of N numbers, each representing number of apples a child has.
<<P.S.>>
Passing an apple means a child giving away one apple to one of its neighbour.
Even if 2 separate children can pass apples simultaneously or one child can pass 1-1 apple to each of its neighbours then that will still be counted as 2 steps and not 1 step.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 2 votes
AnswersGiven a list of quantity of books and corresponding prices.User wants to purchase Q quantity of books. Provide an algorithm which suggest user Q Quantity of books with minimum price
- csgeeg February 17, 2013 in India
e.g
Quantity of Books 10 20 30 15 25
price of books 100 200 120 130 165
user wants to purchase 500 quantity of books.come up with minimum price| Report Duplicate | Flag | PURGE
Amazon Yahoo Software Engineer / Developer Algorithm - 0of 0 votes
AnswersStream has 2 methods
- king Zidane November 15, 2012 in India for Aggregation
char getNextChar()
bool hasNextChar()
Stream is expected to have 1 M characters. Your application cant store them.
Want to find the 1st unique character in the stream| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 0of 0 votes
AnswersYou are given an array which contains coin denominations. e.g. d = {1,2,3,5,8,12,15,21,37,56}. Each of these denominations are in infinite numbers. Write a program to produce the minimum number of coins(with denomination) which sum up to a given value. e.g. 189
- explorer.bit November 14, 2012 in India
output: 3(56)+1(23) = 4
you may produce output as 56->56->56->23| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersDesign any datastructure with three methods insert, delete and getRandom in a highly optimized way. The interviewer asked me to think of a combination of datastructures to design a new one. Insert can be designed anyway but for random and delete i need to get the position of specific element. He gave me a hint to think about the datastructure which takes minimum time for sorting.
- Vikram June 27, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 0of 0 votes
AnswersN players played in a tournament and the results are out. Each player has played all other players. To print out a combination 1,2,3, .. , i-1, i, i+1,....n such that i-1 has lost to player i and player i has lost to i+1.
- anuj78 April 21, 2012 in India
What would be the complexity for the same?| Report Duplicate | Flag | PURGE
Amazon Algorithm Data Structures - 0of 0 votes
AnswersGiven a 2D array, all rows and all columns sorted. Find an integer x from the 2D array.
- KSS March 09, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays - 0of 0 votes
AnswersA sequence of numbers is called a zig-zag sequence if the differences
- topcoder99 December 16, 2011 in India
between successive numbers strictly alternate between positive and
negative. The first difference (if one exists) may be either positive
or negative. A sequence with fewer than two elements is trivially a
zig-zag sequence.
For example, 1,7,4,9,2,5 is a zig-zag sequence because the differences
(6,-3,5,-7,3) are alternately positive and negative. In contrast,
1,4,7,2,5 and 1,7,4,5,5 are not zig-zag sequences, the first because
its first two differences are positive and the second because its last
difference is zero.
Given a sequence of integers, sequence, return the length of the
longest subsequence of sequence that is a zig-zag sequence. A
subsequence is obtained by deleting some number of elements (possibly
zero) from the original sequence, leaving the remaining elements in
their original order| Report Duplicate | Flag | PURGE
Amazon Arrays - 0of 0 votes
AnswersDescribe an algorithm to transfer Binary [Search] Tree exactly from one host to another over network. I assume question is about which traversal order should be used (inorder, postorder, preorder). Interviewer did no provide any feedback on this.
- Michael July 09, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersWrite a function to check if an integer is square or not? Ex, 49 is square, 48 is not.
- anonymous July 04, 2011| Report Duplicate | Flag | PURGE
Amazon - 1of 1 vote
AnswersFind the intersection of 2 unsorted arrays.
- crackit November 24, 2010
The interviewer asked me about the various methods possible and asked me to code one.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersLinked List with following structure..
struct node { int data; struct node *next; struct node *next_larger; }
initially next_larger of every node is point to NULL.
- TheDewarist August 29, 2010
now write a c code which set all node's next_larger pointer.
where next_largest point to the next larger then its own value and largest value node's next_larger pointer points to NULL
i.e.
if LL is 3->1->5->6->4
then 3's next_larger points to 4
and 1's next_larger points to 3
and 5's next_larger points to 6
and 6's next_larger points to NULL
and 4's next_larger points to 5| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Linked Lists - 0of 0 votes
AnswersGiven Numerator and Denominator. After division you might get a recurring decimal points float as the answer. You need to identify the recurring part?
- shukla.swapnil May 22, 2010
For example 23.34563456 ...
return 3456| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given $100 and list of share market values for a period of 30days. You are allowed to make only one buy and one sell. Design an algorithm to maximize the profit.
- Anonymous October 02, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 0 votes
AnswersThere are 9 marbles. 8 of them are of equal weight, 1 is not. You are given a weighing scale. How do you find out which one is has the different weight? Is there a faster solution? What is the speed of your solution?
- Zefram Cochrane November 22, 2008| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Brain Teasers - 1of 1 vote
AnswersFind a median of two sorted integer arrays.
- geeky_freak July 22, 2008| Report Duplicate | Flag | PURGE
VMWare Inc Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven max. travel distance and forward and backward route list, return pair of ids of forward and backward routes that optimally utilized the max travel distance.:
- rahul October 10, 2018 in United States
eg: max travel distance is : 11000
forward route list : [1,3000],[2,5000],[3,4000],[4,10000]
backward route list : [1,2000],[2,3000],[3,4000]
Result : [2,3] ...2 is from forward and 3 is from backward...total distance is 9000...no other combination is there which is >9000 and <=11,000.......0(n^2) solution is straight forward, thinking that sorting both might help.| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 1of 1 vote
Answersgiven a LinkedList like 1->2->3->4->5->6
- ganesh.eng2015 July 30, 2016 in India
Modify it as:
1->6->2->5->3->4| Report Duplicate | Flag | PURGE
Amazon Backend Developer - 0of 0 votes
AnswersPrint the count of duplicate char in a given string in same order. Ex: Input- 'abbaccdbac', Output- 'a3b3c3d1'
- Prashant May 22, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer - 0of 0 votes
AnswersFind the first and last occurrence of a number in a sorted array of integers
- testsync012345 October 23, 2015 in United States for Kindle
For Example: int[] a = {1,2,3,4,5,5,7,8}| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Algorithm - 0of 0 votes
AnswersWrite a code to find if a link list is palindrome . Linklist consists variable string at each node. for eg
- abhi January 12, 2015 in India
a->bcd->ef->g->f->ed->c->ba
The above given linklist is palindrome and func shd return - True| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 1of 1 vote
AnswersReplace %20 with ' '.
- Lawjick October 16, 2014 in United States
E.g. input: www.space%20.com
output: www.space .com| Report Duplicate | Flag | PURGE
Amazon SDET String Manipulation