Amazon Interview Questions
- 3of 3 votes
AnswersWrite a function to label connected components (using 4-connected neighbors) in a binary image.
- davydany August 01, 2014 in United States
You may use any language or data structures, but you may not use any existing APIs/libraries to find the components.
Example:
Input image
0 0 0 0 0 1 1 0 0 0
1 1 0 0 1 1 0 0 0 0
1 1 1 0 0 1 1 0 0 0
0 0 0 1 1 0 0 0 0 0
Output Image
0 0 0 0 0 1 1 0 0 0
2 2 0 0 1 1 0 0 0 0
2 2 2 0 0 1 1 0 0 0
0 0 0 3 3 0 0 0 0 0| Report Duplicate | Flag | PURGE
Amazon Research Scientist Algorithm - 3of 3 votes
AnswersGiven an array of 1 billion numbers with just a few 100 missing, find all the missing numbers. you have only enough memory to store only 10k elements
- PS October 07, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon Senior Software Development Engineer Algorithm - 3of 3 votes
AnswersDesign a Restaurant Reservation system.
- learner January 09, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Object Oriented Design System Design - 3of 3 votes
AnswersGiven the root of a Binary Tree along with two integer values. Assume that both integers are present in the tree.
- teli.vaibhav October 30, 2016 in United States
Find the LCA (Least Common Ancestor) of the two nodes with values of the given integers.
2 pass solution is easy. You must solve this in a single pass.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 3of 3 votes
AnswersDesign backend system for bookMyShow.com like system which supports below use cases:
- Priyanka March 29, 2017 in India
1) When user selects cities, list of cities is displayed.
2) When user selects city, movie list is displayed.
3) When user selects movie, list of theatre is displayed.
4) When user selects theatre, show timing is displayed.
5) When show timing is selected, user is asked for no of seats that he wants to book
6) When user selects no of seats, seats are displayed to choose from.
7) When user selects seats, then total price is displayed.
8) When total price is selected, then user is directed to payment gateway and payment is done and on payment success, ticket is mailed to him.
More questions on how can we scale the system, and handle concurrent users request for same seat etc.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Object Oriented Design - 3of 3 votes
Answerswhen we have to override equals and hashcode in java..?
- PRASHANTGAURAV November 12, 2013 in India
what will happened if you dont override .. Explain with program.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Java - 3of 3 votes
AnswersWrite a class that will have following functions:
- JSDUDE May 04, 2013 in United States
long CheckOut()
CheckIn(long)
Range of values is 1 to LONG_MAX
At any given point in time checkout should return the minimum available LONG number
Checkin can return the value back
No need to check for border conditions (e.g. check out when all values are exhausted)
Implement:
1. long checkout()
2. void checkIn(long input)| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 3of 3 votes
AnswersA soccer league has n matches with A,B,C teams with number of goals scored by each team in each match.If a team wins against another team ,It gets 3 points and lost team gets 0 point.If a tie ,both team gets 1 point.Now how do you frame the ranking of teams.
- sriramMS December 20, 2012 in United States
1) All teams played n matches.
2) A team 1 match,B Team 2 matches, 3 team 3 matches.Like wise it goes.
They looked for coding and data structure techniques.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Data Structures - 3of 3 votes
AnswerDesign Uber or Lyft like architecture keeping scale, latency and availability in mind. The design can be at macro level first, that is, major components like persistent store (SQL/NoSQL/redundant), cache, communication/messaging. The design and if time permits, details will then be discussed/challenged.
- Blue Ocean November 29, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Principal Software Engineer Distributed Computing - 3of 3 votes
AnswersHow to find out distinct ngrams from a email_alias.
- ashwini.padhy89 December 05, 2018 in India
For instance xyz@gmail.com here the email_alias is xyz.for xyz if we want to find bigram then function should have input the email_id,and the number of grams lets say 2.
Than it has to return the distinct count of ngrams present in the email_alias.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Coding - 3of 0 votes
AnswersWrite a code to calculate kth power of a matrix of size nxn. You can assume that matrix multiplication is O(n^3).
- Meghna December 05, 2008| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Matrix - 3of 0 votes
AnswersGiven an array of positive and negative numbers, find the maximum sum of any subsequence. Return both the sum and the subsequence.
- xmagics August 31, 2008| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 2of 6 votes
Answersthere is an infinite line.you are standing at a particular point you can either move 1 step forward or 1 step backward.you have to search for an object in that infinite line.your object can be in any direction. Give optimal algorithm.
- Amit September 03, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon - 2of 6 votes
AnswersGiven an array of n numbers with repetition of numbers. You need to find the max length of continuous sub array with at max 3 unique elements.
- Nascent August 05, 2013 in India
For eg
array: 1 2 3 1 4 3 4 1 2
ans: 6 (3 1 4 3 4 1)
Solution: Time complexity O(n)
Extra Space O(1)| Report Duplicate | Flag | PURGE
Amazon - 2of 4 votes
AnswersA string contains a-z, A-Z and spaces. Sort the string so that all lower cases are at the beginning, spaces in the middle and upper cases at the end. Original order among lower and upper cases needs to remain the same. For example: a cBd LkmY becomes ackm BLY. Is there a way in O(n) without extra space?
- chad August 13, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Algorithm Arrays - 2of 4 votes
AnswersGiven an Array, replace each element in the Array with its Next Element(To its RHS) which is Larger than it. If no such element exists, then no need to replace.
- R@M3$H.N March 03, 2014 in United States
Ex:
i/p: {2,12,8,6,5,1,2,10,3,2}
o/p:{12,12,10,10,10,2,10,10,3,2}| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 4 votes
AnswersHaving a table Genre with two colums (Id, Genre) make an SQL Query that finds the Ids with the genre Action and Comedy. (those will have multiple lines for each Id)
Answer:
- mikeldi10 June 19, 2014 in UK for Amazon Instant Videoselect g.id from (select id from genre where genre = 'Action') x, genre as g where g.id = x.id and genre = 'Commedy'
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer SQL - 2of 4 votes
AnswersGiven a Binary tree and a arbirary node of that tree , find all the nodes at a Distance of K from that Node .Nodes DON’T have parent pointers
- Rahul Sharma January 19, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 4 votes
AnswersHow many squares are present in an NxN grid?
- Murali Mohan March 27, 2014 in India
In an MxN grid, how many squares are present and how many rectangles?| Report Duplicate | Flag | PURGE
Amazon Computer Scientist Math & Computation - 2of 4 votes
AnswersSearch in a row wise and column wise sorted matrix
- vinod January 24, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Intern Matrix - 2of 4 votes
AnswersGiven two sorted arrays, find the median of each array. The length of the arrays are m and n and we should not use extra buffer. We should find the median and time complexity should be less than 0(M+N);
- alregith June 02, 2013 in India for Chennai| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Data Structures - 2of 4 votes
AnswersA frequent traveller collects all his travel tickets.
- rd22 September 24, 2016 in India
A ticket has only 2 attributes, Start Journey Location name and Destination Name. Example from Delhi to Mumbai.
At the end of the year, the traveller gets all his tickets together and tries to map his journey across the year. Print his travel route in a readable format. He does not remember his start location.
Edit: he can visit a location multiple times, and can also go back and forth a place several times.| Report Duplicate | Flag | PURGE
Amazon Algorithm - 2of 2 votes
AnswersRound 1: Q2:
- Abee July 20, 2011
Puzzle
Given 25 horses, find the best 3 horses with minimum number of races. Each race can have only 5 horses. You don't have a timer.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Brain Teasers Highbridge Capital Deshaw Inc - 2of 2 votes
Answersfind the longest palindrome in a string?
- handiaya November 09, 2009| Report Duplicate | Flag | PURGE
Microsoft Amazon Software Engineer / Developer Algorithm Arrays C++ Coding String Manipulation C - 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 - 2of 2 votes
AnswersHow to find in a binary tree, whether all leaves are at same level or not, and return a boolean value after identifying this.
- seth June 04, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures