Amazon Interview Questions
- 1of 1 vote
AnswersTotal number of steps are given (let N)
- MI December 28, 2012 in India
at a time you can take one or two steps..
Q total number of ways to reach N.
My Ans: find out total number of non -ve solution to the
equation X + 2Y = N
For every pair of value, find out total number of arrangement. Ex X = x and Y = y
then arrangement is (x+y)!/(x! * y!).
I think my answer is correct but interviewer was not convince.. may be he is looking some mugged answer ..| Report Duplicate | Flag | PURGE
Amazon - 1of 1 vote
AnswersWAP to check a tree is symmetric.
- Anonymous August 06, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Algorithm - 1of 1 vote
AnswersYou are given a sorted array that is rotated circularly from a particular point. for example 12345 rotated about 3, circularly is 34512
- someone June 28, 2010
you have to search for a number in that list
in O(lgn)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
Answersgiven a number, 9th bit set or not?
- Anonymous April 12, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Bit Manipulation - 1of 1 vote
AnswersWrite a code to remove the characters from string1 which are present in string2.
- Meghna December 05, 2008| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer String Manipulation - 1of 1 vote
AnswersGiven directory change command -
- neer.1304 June 10, 2019 in United States
cd a/b/../c/d/e/../../
Output the visit count for each directory such as -
Root - 1
a - 2
b - 1
c - 2
d - 2
e - 1| Report Duplicate | Flag | PURGE
Amazon SDE-3 Algorithm - 1of 1 vote
AnswersI've got these trees of integers; they're like regular trees, but they can share nodes.
- NinjaCoder July 20, 2017 in United States
I need to know if any branch of this tree sums to 100.
7
/ \
8 6
/ \ / \
2 3 9
/ \ / \ / \
5 4 1 100
Follow up question was how would you change the code to handle negative numbers| Report Duplicate | Flag | PURGE
Amazon - 1of 1 vote
AnswersA company is looking for algorithm to show item recommendations.
- maksymas August 29, 2016 in United States
If a customer bought A and B items and another buys A item, B should come as recommendations.
There are two types of recommendations based on the connections
1) Two items are strongly connected if a customer buys those items.
2) Two items are weakly connected if each items are strongly/weakly connected to another third item.
Provided the sample input
ABC
10
first:ABC
first:HIJ
sec:HIJ
sec:KLM
third:NOP
fourth:ABC
fourth:QRS
first:DEF
fifth:KLM
fifth:TUV
first, sec, third.. represents the customer names
ABC, HIJ... represents the item codes
For the Input item Id "ABC", since "ABC" is strongly connected to HIJ, DEF, QRS
and whereas ABC is weakly connected to KLM and TUV
the output should be count of strong and weak connection i.e., [3,2]| Report Duplicate | Flag | PURGE
Amazon Software Developer Algorithm - 1of 1 vote
Answers2. Suppose you are given a puzzle that is represented as a matrix with 0s and 1s, where a 0 indicates you’re allowed to move into that position and 1 means you’re not allowed to move in that position. Write a function that given a start position and an end position, returns a boolean value indicating if there exists a path from start to end. You are only allowed to move up, down, right or left. Diagonal movement is not allowed.
- laurentr September 18, 2015 in United States
Example #1
Input
0 0 1 0 1
0 0 0 0 0
0 1 1 1 1
0 1 1 0 0
start: 4,1
end: 0,3
Output
true
Example #2
Input
0 0 1 1 1
0 1 0 0 0
1 1 1 1 1
0 0 0 0 1
start: 0,0
end: 1,2
Output
false
Example #3
Input
0 0 1 1 1
0 1 0 0 0
0 1 1 1 1
start: 0,0
end: 2,1
Output
False
class Position {
final int x, y;
public Position(final int x, final int y) {
this.x = x;
this.y = y;
}
}
boolean pathExists(int[][] puzzle, Position start, Position end) {
// your code goes here
}| Report Duplicate | Flag | PURGE
Amazon Software Developer - 1of 1 vote
AnswersGraph problem:
- manidam07 March 30, 2015 in India
Critical node: If a node reaches another node only through one node.
Eg: A-C-B and A-E-B are critical nodes. (A reach B through one node which is C or E)
If A reaches B through more than one node, then they are not critical nodes.
1) A-C-B
A-D-E-B (A reach B thro C which might lead to critical node but A has another path to B thro D and E, so they are not critical nodes).
2) X-Y-Z
X-A-Z (X and Z are critical nodes)
Now find all critical nodes.| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Algorithm - 1of 1 vote
AnswersDesign a valet parking system. Requirements of the valet parking system should be:
- LCHammer September 25, 2014 in United States for Advertising
1. Customer are given a ticket that they can use to redeem to get their vehicle back
2. Parking spots come in three sizes, small, med, large
3. Thee types of vehicles, small, med, large
-a small vehicle can park in a small, medium, and large spot
-a medium vehicle can park in a medium and large spot
-a large vehicle can park in a large spot| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 1of 1 vote
AnswersWe are given an unsorted array of n^2 arbitrary numbers, and we must output an n x n matrix of all the inputs such that all the rows and columns are sorted. For example, suppose n=3, n^2=9, and the 9 numbers are just the integers {1,2,...,9}
Possible ouputs include:1 4 7 1 3 5
2 5 8 2 4 6
3 6 9 7 8 9
Show how to sort this array with a Ω(n^2log n) lower bound.
- randyma12 September 14, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Computer Scientist Algorithm - 1of 1 vote
AnswersA new Kindle feature is being developed to rank customers based on their reading speed.
- camiloa136 June 26, 2014 in Vancouver
A customer's "reading speed" is the maximum number of pages they have read in a single minute over the previous 10 minutes. Every minute, we will log the customer's current page, which can be used to calculate this speed. For example:
Current Time: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15]
Current Page: [0, 5, 6, 8,12,15,17,21,24,27,29,31,37,42,49,52]
Current Speed: [0, 5, 1, 2, 4, 3, 2, 4, 3, 3, 2, 2, 6, 5, 7, 3]
"Reading Speed": [0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 6, 7, 7]
We want to produce separate leaderboards for each book. Each customer will only read one book at a time, but multiple customers may read the same book.
Every minute, the "updateReadingSpeeds" method will be called to report each customer's reading progress. Please implement this method:
void updateReadingSpeeds(String customerID, String bookID, int pageNumber)
At any time, we should be able to request the full leaderboard for any book. Please implement the "printLeaderboard" method:
void printLeaderboard(String bookID)
The output should be CSV printed to standard output, like:
Customer ID,Reading Speed,Rank
Customer 1,5,1
Customer 3,4,2
Customer 2,4,3
Customer 5,2,4
*The updateReadingSpeeds method will be called every minute for every customer.
*CustomerID will uniquely identify a customer, bookID will uniquely identify a book
*Page numbers are integers between 0 and 1000000, and will never decrease over time.
*Customers who "tie" with the same reading speed can be ranked in any order.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersFor a given binary search tree, replace each node with sum of all node which are greater then of equal to current node.
- Razz May 02, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 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 - 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 - 1of 1 vote
AnswersWrite a routine to reverse every k nodes in a given linked list without using additonal memory.
- anon123 February 16, 2014 in United States
input : 1,2,3,4,5,6 k:3
output : 3,2,1,6,5,4| Report Duplicate | Flag | PURGE
Amazon - 1of 1 vote
AnswersHow will you Serialize and Deserialize the binary tree?
- vinod January 21, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Intern Algorithm - 1of 1 vote
Answerscreate the mirror tree for the given BST, provided with the root node of the tree
- saran August 10, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Intern Trees and Graphs - 1of 1 vote
AnswersIn an N*M grid, in how many ways can you reach from top left (0,0) position to an arbitrary location (i,j) provided you can only move to the right or to the bottom in one step?
- Murali Mohan July 22, 2013 in India for Bangalore
How do you compute the number of ways from (0,0) to (i,j) if there are arbitrary number of blocks on the way?| Report Duplicate | Flag | PURGE
Amazon SDE-2 Problem Solving - 1of 1 vote
AnswersString [] [] matrix = {{"A","N", "L", "Y", "S"},{"I", "S", "D", "E", "S"},{"I", "G", "N", "D", "E"}};
- gohilumesh July 05, 2013 in United States
// 2. Given a word "DES"
// 3. Write a program to find the occurences of this word "DES". Letters must be next to each other in the matric.
// 4. "Next" means: left, right, up, down, left down, right down, upper left, upper right
// 5.. For example: S at (1,1): A, N, L, D, N, G, I, I are next to S at (1,1)
Required output
// // D - [1, 2], E - [1, 3], S- [1, 4]
// D - [1, 2], E - [1, 3], S- [0, 4]
// D - [2, 3], E - [2, 4], S - [1, 4]
// D - [2, 3], E - [1, 3], S - [0, 4]
// D - [2, 3], E - [1, 3], S - [1, 4]| Report Duplicate | Flag | PURGE
Amazon SDE1 Matrix - 1of 1 vote
AnswersWrite a C program to find the number of shift required to convert one string to another. Check all the corner cases.
- techieDeep May 04, 2013 in United States
Eg: abc to acb o/p shd be 2 as 'b' shifted from 1st index to 2nd and 'c' shifted to 1st from second.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersWrite a program to find the mirror image of a binary tree?
- balarajesh.b December 17, 2011 in India for kindle
if a tree is like
01
02 03
04 05 06 07
The mirror will be like
01
03 02
07 06 05 04| Report Duplicate | Flag | PURGE
Amazon Production Engineer Algorithm - 1of 1 vote
AnswersI just took my Amazon 1st round of telephonic interview. The interviewer asked me to code something, which I was not confident with coding and I said my coding skills were rusty. I wasn't expecting coding question over telephone. In total he just asked me 4 questions:
- jobhunter May 26, 2011
-- diff btw linker and loader
-- what all happens in compilation steps
-- imagine we have 100,000 students, and each has some marks. We have to rank students on their marks.
-- an array of n integers. how to find pairs which sum up to k.
He ended my interview in 30 minutes, where the HR said it would last for an hour.
Does it mean that he was disappointed with me and found me hopeless. My communication skills though were bad. I could not express myself properly.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Ideas - 1of 1 vote
AnswersFind the two integers in an array whose sum equals to a given value
- Anonymous August 04, 2008| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersIdentifying if all the elements of a set (in enterity) is present in a list of sets.
- hulk July 11, 2017 in India
For example checking for set1 = {1,2} in {1,2,3}, {5,6} should return true as {1,2} is present in {1,2,3}. Similiary it will be true for {1,2,8,9}, {1,2,4}
But checking for {1,2} in {1,5,6}, {2,3,1} should return false as {1,5,6} does not contain all elements of {1,2} 2 is missing| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 1of 1 vote
AnswersGiven a log file:
- AnonymousN December 15, 2015 in United States
some garbage...from:123.54,78.21...more garbage..to:56,82,124.54...more
some more garbage...from:11.54,45.84...garbage..to:115.87,98.65
...
Write a program or shell script to return pairs of (from, to) coordinates.
Assumption: these coordinates will always appear in sequence: from ... to... from ... to...
But these from - to pair may or may not be on same line.| Report Duplicate | Flag | PURGE
Amazon SDE-2 shell scripting - 1of 1 vote
AnswersWrite a function which does zig-zag traverse of binary tree and prints out nodes.
- Eugene July 16, 2015 in United States
Example:
1
2 3
4 5 6 7
Output: 1, 2, 3, 7, 6, 5, 4| Report Duplicate | Flag | PURGE
Amazon Software Engineer - 1of 1 vote
AnswersMake a function that shows the common elements in two arrays. Part 2: With duplicates (small explanation). Part3: without duplicates
Answer:
- mikeldi10 June 19, 2014 in United States for Amazon Instant Videoint[] intersect(int[] array1, int[] array2){ if(array1.lentgh == 0 || array2.length == 0) return {}; Set<Integer> set = new HashSet<Integer>(); for(int i = 0; i < array1.length ; i++){ set.put(array1[i]); } List<Integer> list = new ArrayList<Integer>(); for(int i = 0;i < array2.length ; i++){ if(set.contains(array2[i])){ //map.put(map.get(array2[i])-1); //short explanation of how to do it with dupplicates set.remove(array2[i]); list.add(array2[i]); } } return list.toArray(); }
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm