Amazon Interview Questions
- 4of 4 votes
AnswersGiven a random generator rand(5) which generates numbers between 0 to 4. How do u generate numbers between 0 to 6, I.e. Implement rand(7).
- hulk April 16, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Brain Teasers - 4of 4 votes
AnswersCar parking problem. An array given represents actual order of cars need to be parked. Like for example order is 4,6,5,1,7,3,2,empty. If cars are parked in some order like empty,1,2,3,7,6,4,2. Some person needs to get them into correct order, list out all instructions to the person to get in correct order with least number of swaps.
- hulk April 16, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersConsider a game of chess where there is a special queen which has the powers of a Queen as well as a Knight. For eg. in the following arrangement, squares marked with 'x' are in the attackzone of the special queen and the ones marked '0' are in the safe zone:
- rohit.agarwal88 April 16, 2014 in India
x O O x O O x
O x x x x x O
O x x x x x O
x x x Q x x x
O x x x x x O
O x x x x x O
x O O x O O x
Your task is to determine the number of ways in which you can place M such queens on a MxM chess board so that they are in equilibrium i.e. they are placed such that no queen is in the attack zone of the other.
Assume M<15. If you need coordinates to identify each square, you can assume that the top-left square is marked (1,1) and the bottom right square is marked (M,M).| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 2 votes
Answersgiven a N x N matrix find the no. of times a word is present in that matrix. constraints you can move in 3 directions from one cell 1. forward , 2. down 3. diagonal . Find all teh occurance of all the word
- GOOGLE_SDE April 15, 2014 in United States
forward means right (x+1,y)
down mean (x,y+1)
diagonal means (x+1,y+1)
it can be done with BFS. {search the no. of occurance of a given word example "sachin" in the whole NxN matrix}
w | s | r | t | g | g|
a | a | c | h | i | n |
k | c | h | u | j | j |
o | h | i | n | y | q |
in this sachin can be found out 3 times.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersI attended a telephonic round for appstore testing and successfully cleared this round. Following was the 2nd question(apart from tell me abt yourself,etc):
- i_learn April 11, 2014 in India for for appstore
Give all testcases for creating and renaming a folder in a parent directory, say c drive| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance Android Application / UI Design test Testing - 1of 1 vote
AnswersI attended a telephonic round for appstore testing and successfully cleared this round. Following was the First question(apart from tell me abt yourself,etc):
- i_learn April 11, 2014 in India for for appstore
Give me all possible test cases for gmail registration page.| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance Android Application / UI Design System Design test Testing - 2of 2 votes
Answersgive me the code for :
Given a string say "I am a human being" the output should reverse all letters of each word but not the whole string as such.
Eg: O/p should be "I ma a namuh gnieb"
I somewhat wrote the code, but i was asked what if there are extra spaces etc.
(i am able to write the code sitting at my desktop at one short but there front of interviewer i am struggling. Need to build up my confidence)
let me know the best and optimised way of writing this code.
Also i suggest people to aviod using inbuilt functions as much as possible
My Answer is as below in perl
- i_learn April 11, 2014 in India#i want the reverse of the letters of all words in a string #eg Input is "I am a human being" then o/p shud be "I ma a namuh gnieb" $str="I am a human being"; @arr=split(' ',$str); print @arr; for($i=@arr-1;$i>=0;$i--) { $_=@arr[$i]; ####intead of above for loop if we use foreach(@arr) then it will reverse the whole string @word=split('',$_); { foreach $n (@word) { unshift(@final,$n); } } } print "\n @final \n";
| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance Algorithm Android Application / UI Design Arrays Automata Coding Data Structures Dynamic Programming Perl - 0of 0 votes
Answersgive me a code to find all anagrams or combnations of a given work.
- i_learn April 11, 2014 in India
Say if the word given was "hello"
then
hel
he
hell
leho
lleho
and so on| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance Algorithm Android Application / UI Design Arrays test Testing - 0of 2 votes
AnswersGiven an array say [0,1,2,3,5,6,7,11,12,14,20]
- i_learn April 11, 2014 in India
given a number say 5.
Now find the sum of elements which sum to 5
eg:2+3=5, 0+5=5 etc.
I guess the interviewer wanted all possible combinations eg 0+2+3=5, etc| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance Algorithm Android Application / UI Design Arrays Coding Data Structures Dynamic Programming Perl Sorting test Testing - 0of 2 votes
AnswersA very interesting Question to be done in C or C++ as platform:
- chaos April 10, 2014 in United States
Given two input files.
Input file1.csv
Each line in the file describes a websites.
The first field is unique identifier for the site, the second field is the minimum amount in cents, the third field is a string that is the site’s URL:
2181, 320, abc.com
3288, 450, pqr.com
9662, 567, xyz.com
2675, 721, lmn.com
6434, 500, rst.com
8123, 5000, jjj.com
Input file2.csv
Each line in the file describes an ad. The first field is a 32bit unsigned integer which is the unique identifier for the ad , the second field which is the maximum amount in cents the ad is willing to pay to show on a site, the third field specifies the number of sites the ad wants to display on, followed by the site_ids of the sites.
9822, 450, 3, 2181, 9662, 66434
3421, 897, 3, 2675, 9662, 3288
8961, 342, 1, 9662
7623, 2000, 3, 2181, 2675, 9662
all integr fields are 32bit unsigned integer
In the above example, ad 9822 is willing to play on 3 sites(abc.com, xyz.com and rst.com) and pay a maximum amount of 450 cents. WAP that decides the appropriate ad by applying the following rules
1. An ad can be shown on this site only if the site is in the list of sites that the ad is interested in.
if no ad id found for a ite, then no ad is returned
2. The ad that is returned is chosen an auction thats is called second price auction. For ads to qualify for the second price auction,
auction for a site their bid_price should be greater than or equal to the reserve_price of the
site. The winner of the auction is the ad that has the maximum bid_price among these ads, and this
winning ad pays the second highest ad’s bid_price. For instance, if two ads with bid_price 500
and 600 are competing for a site that has a reserve_price of 400, then the ad that bid 600 wins,
but pays 500 (the second highest ad’s bid price).
3. In case of a tie between two or more ads, the ad with the lower ad_id wins and pays it’s
bid_price. In case, the auction has only one ad that qualifies, then that ad wins and pays
reserve_price of that site.
4. In case there are no ads that qualify for the auction for a site either because no ad expresses interest
in playing on that site or because none of the ads have bid_price greater than or equal to
reserve_price of that site then no ad is returned.
Your server should accept input file path,first.csv and the second.csv as
arguments and wait for input. The input is the site_id and the adserver should return the ad_id of the ad that wins the second price auction and price the ad pays for the display. An input of 1 ends the program. example:
$ ./adserver sites.csv ads.csv
2675
7623 897
3288
3421 450
6434
0 0
9999
0 0
8123
0 0
1
$
DIRECTIONS:
1. The code should compile at least on
http://www.compileonline.com/compile_cpp_online.php
2. Please note that will test your program on larger input files with 20K+ sites and
20K+ ads.
3. You have 1.5 hour to solve the problem, test and submit your solution. Your goal is to provide a working solution at least. You may submit additional code later if you think you can make it work better or faster.
For starters If I were to do this in Java:
Algo:
Step1: I/O
Store both the File Paths from STD IN
Take the SITE_ID as Input Then
Step 2: Pre Processing
Site_Map:
Create a Dictionary/HashMap of All the Site_ID and their Price
Ad_Map:
Create a Dictionary/HashMap of All the Ad_ID and the Ammount they Have
Site_to_Ad Map:
Create a Dictionary/HashMap of All the Site_ID and the Ad_IDs Interested to be on them.
Step 3: Auction Method
Iterate through the Site_to_Ad Map.
Fetch the Amount for Each ad_id from the Ad_Map
Compare it against the min price and if greater store it in a variable along with the ID. Fetch the Next ID and IF it is Higher, Replace and put this value in the variable. If there is a draw, compare the two ap_ids and store the one that has min ad_id value.
If min bid is not reached or if there are no ad_id values for that site, return no ad.
Add Constraints to the Auction block.
I believe in c++ we would use Dictionaries to achive this as we have HashMap in Java, can someone help m with the syntax.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersHow would you debug a Linux program taking too much memory.
- aks April 08, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 1of 1 vote
AnswersThere are 2 sets A and B of numbers where numbers are keep coming at high speed. At any given time, you need to find 'A UNION B', 'A INTERSECTION B', 'A - B' and 'B - A'.
- aks April 08, 2014 in India
How will you store numbers and how will you find these value in real time?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersRound 3 of the interview(in person)
- lei April 07, 2014 in CANADA
On amazon website, what does the request most recent viewed items API look like?
On server side, design a data structure to cache the most recent viewed item for all clients( consider the size of amazon user)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersRound 3 of the interview(in person).
- lei April 07, 2014 in CANADA
given a binary tree with each node contains a number (with negative, duplicate number), write program to find the level which have the most num of negetive number.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a huge file 100 million integers. He further divided the file into 100 files with 1 million integers in each and each file is sorted. Needed to find the k smallest integers.
- pulkit.mehra.001 April 07, 2014 in India
I used the concept of min-heap. Take the first element from each file and construct a min-heap. Take the root,as it is the smallest element and insert the next element from the file which contains the root root element. Heapify the tree and repeat k times.
The interviewer asked if another efficient method exists?| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersAmazon is considering introducing a customer loyalty program, which rewards members with Amazon Dollars on purchases. The program encourages members to be sponsors and recruit other shoppers to join. Purchases made by recruits are then rewarded to the sponsor. The chain of recruits can be arbitrarily deep. Any purchase by a member is counted towards that member (10% of purchase price), their sponsor (4%), their sponsor’s sponsor (4% of 4%), their sponsor’s sponsor’s sponsor (4% of 4% of 4%), etc. Finally, a sponsor can have any number of recruits, but any one recruit can only have one sponsor.
- kdaryani@hawk.iit.edu April 04, 2014 in United States
Write a function that calculates the payout for a given member.
Given the following interface, please implement the MemberPayoutUtil.calculatePayout function.
public interface Member {
public double getMonthlyAmazonDollars();
public Collection<Member> getRecruitedMembers();
}| Report Duplicate | Flag | PURGE
Amazon Java Developer - 5of 5 votes
AnswersGiven stock price of Amazon for some consecutive days. Need to find the maximum span of each day’s stock price. Span is the amount of days before the given day where the stock price is less than that of given day
- Rahul Sharma April 04, 2014 in India
E.g i/p = {2,4,6,9,5,1}
o/p= { -1,1,2,3,2,-1}| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 1of 1 vote
AnswersGiven a matrix of characters and a string, find whether the string can be obtained from the matrix. From each character in the matrix, we can move up/down/right/left. for example, if the matrix[3][4] is
- Rahul Sharma April 04, 2014 in India
o f a s
l l q w
z o w k
and the string is follow, then the function should return true.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 2 votes
AnswersHow would you maintain concurrency on a shared page being edited by multiple users simultaneously.
- chaos April 03, 2014 in United States
What if the page is being shared using a client- server mechanism. Represent the classes and explain the thread safety mechnism to avoid editing conflicts.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Threads - 0of 0 votes
AnswersGiven 2 strings str1 and str2. What is the efficient way to navigate from str1 to str2? The constraints are i) a string can be changed to another string by changing only one character. ii) all the intermediate strings must be present in dictionary. If not possible, return “not possible to navigate from str1 to str2″. (pre-processing is allowed and enough memory is available). for example: str1 = feel and str2 = pelt, then the navigation is feel -> fell -> felt -> pelt
- Rahul Sharma April 03, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Coding - 3of 3 votes
AnswersGiven a set of intervals like 5-10, 5-10, 8-12, 9-15
- blackfever April 03, 2014 in India
Find the ith smallest number in these intervals.
for eg:-
Suppose we have intervals like 5-10, 8-12.
Then total numbers in these two intervals would be: {5,6,7,8,8,9,9,10,10,11,12}
So, 1st smallest number: 5
4th smallest number: 8
5th smallest number: 8 (here is the
change since now we have duplicate elements also) and so on.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersHow would you store a phone book. Unique phone numbers, possibly multiple same names with different phone numbers.
- georgiosziazopoulos April 03, 2014 in Luxembourg| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersArray of Integers with even number of same Integers. Find the Integer that is an odd number of times. Compare efficiency between different approaches.
- georgiosziazopoulos April 03, 2014 in Luxembourg| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersGiven a string, find the largest repetitive sequence. Algo + Code
- sameer.careercup April 02, 2014 in India
Ex: abcdefbcd – bcd, banana – ana| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Algorithm - 1of 1 vote
AnswersSliding window problem where window size is 3 and we need to find the minimum from the window.
- Vaibhavs April 02, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersGiven a list with duplicate values find the first unique elements in it.
- Vaibhavs April 02, 2014 in United States
for eg: BH BH F AL HJ AL HJ PK
so answer is F| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersGiven a matrix and need to traverse through it last position from first position and the matrix has 0 and 1 if there is 1 we cant proceed ahead.
- Vaibhavs April 02, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersCompare two release version and tell me which is larger
- Vaibhavs April 02, 2014 in United States
eg: 1.0.10 and 1.0.2
1.0.2 is greater
1.2.0 and 2.1.0
2.1.0 is greater| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm