Amazon Interview Questions
- 0of 0 votes
AnswersGiven an array of integers, replace every number with the next higher number to its right. If a number can’t be replaced, we leave it as-it is.
- neer.1304 August 30, 2017 in United States
For example, the list: 5, 2, 1, 4, 6, 7 needs to be changed to 6, 4, 4, 6, 7, 7.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersGiven two unsorted arrays A, B. They can contain duplicates. For each element in A count elements less than or equal to it in array B
- neer.1304 August 30, 2017 in United States
Examples:
Input : A = [1, 2, 3, 4, 7, 9]
B = [0, 1, 2, 1, 1, 4]
Output : [4, 5, 5, 6, 6, 6]| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersWrite a logic to print the elements of 2D matrix in a spiral way?
- explorer August 25, 2017 in United States
for eg if int[][] matrix = {{1,2,3,4}{5.6,7,8}{9, 10, 11,12}};
The output should be 1 2 3 4 8 12 11 10 9 5 6 7
The interviewer asked me to implement a recursive algorithm.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersGiven a continuous stream of numbers, write a logic to find k maximum numbers at any given point of time where k is fixed?
- explorer August 25, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswerGiven some set of points in each quadrant of a 2D graph and two edges at a fixed angle, find the minimum angle at which the edges would cover maximum points between them?
- explorer August 25, 2017 in United States
I was confused on how to start and interviewer hinted me to consider each point at some angle from base (say 0) and continue finding all points which lies within the fixed angle.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a binary tree, how do you serialize and deserialize. Remember it is not BST it is a general binary tree which can also have duplicate elements.
- agrawal.arpit35 August 22, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersFind the largest repeating sub-string in a string.
- Constantine August 22, 2017 in United States
ex: banana
ans is: ana| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersYou are given a log file with the bandwidth information of users in several lines.
- dj16 August 19, 2017 in United States
Bandwidth info for a certain user may be repeated.
User:A Bandwidth:50 CountryCode:IND
User:B Bandwidth:60 CountryCode:USA
User:A Bandwidth:70 CountryCode:IND
(i) Find total amount of bandwidth consumed per user
(ii) Suppose there are 4 country codes, for every country code, find the top 5 users which consumed maximum bandwidth sorted.| Report Duplicate | Flag | PURGE
Amazon - -1of 1 vote
AnswersGiven a matrix. Convert it into a linked list matrix such that each node is connected to its next right and down node.
Ex:
1 2 3
4 5 6
7 8 9
Output:
1->2->3->NULL
| | |
v v v
4->5->6->NULL
| | |
v v v
7->8->9->NULL
| | |
v v v
--NULL-
This is my code.class Ideone { public static void main(String args[]) throws Exception { int arr[][] = { { 1, 2, 3 }, { 4, 5, 6 } }; LList op = convert2DArrintoList(arr, 0, 0); System.out.println(op); } public static LList convert2DArrintoList(int arr[][], int col, int row) { if (col >= arr[0].length || row >= arr.length) return null; return new LList(arr[row][col], convert2DArrintoList(arr, col, row + 1), convert2DArrintoList(arr, col + 1, row)); } static class LList { LList(int data) { this.data = data; } LList(int data, LList down, LList next) { this.data = data; this.down = down; this.next = next; } LList() { this.data = Integer.MAX_VALUE; } @Override public String toString() { return " " + this.data + " "; } int data; LList next; LList prev; LList rand; LList down; } }
Are there better ways of doing it?
- koustav.adorable August 16, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
Answers// Create a numeric binary tree structure/classes that have left and right children and an integer numeric value.
- deepmh August 14, 2017 in United States for Amazon Fresh
// Write a function 'isBalanced' for a node that returns true if the sum of all the children on the left is equal
// to the sum of all the children on the right.
//Example:
// [12] [12].isBalanced() -> True. [3, 3]
// / \
// [3] [1] [1].isBalanced() -> True. [2, 2]
// / \
// [2] [0]
// / \
// [2] [0]
// - Part I: setup and isBalanced() function
// - Part II: implement “allBalancedNodes()” <— given a node, finds all balanced children
// allBalancedNodes(12) -> returns a list of balanced nodes: { [1], ... }| Report Duplicate | Flag | PURGE
Amazon SDE-3 Data Structures - -1of 1 vote
AnswersGiven a fully connected graph with n nodes and corresponding values. One node can interact with other node at a time, to replace/ignore/add its value to other node’s value. Assuming this operation takes 1 unit of time, how much time would it take for all the nodes to have value equal to sum of all the nodes.
- koustav.adorable August 14, 2017 in United States
Examples : Given a graph with values {1,2,3,4}, find total time it takes, such that all nodes have value as 10.
I am assuming it can be done in O(N).It will take basically two traversals, one for calculating the sum of values of nodes(first traversal), other for replacing the value of the nodes(second traversal).
It will take 2*(no of nodes) time.
Are there any better ways possible ?| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 0of 0 votes
AnswersDesign amazon's frequently viewed product page.
- Nascent August 11, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 0of 0 votes
AnswersDesign a ESPN like system. Ensure scaling and availability. Also one should get all details like score of a player, no. of mtches etc.
- Nascent August 11, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 2of 2 votes
AnswersDesign a FIDS(Flight Information Display System)
- AD August 04, 2017 in India
1. Consider most important classes & ignore Interfaces as of now
2. FIDS is not about reservation system but the dasboard to display
3. the information will look like:
DEPARTURES
----------------------
Attributes:
STD Airline Flight Destination/Via CheckInCounter# Gate Status ETD
Values :
12:50 KingFisher 6E352 Hyderabad A-B 23 Check-In Open 13:15
ARRIVALS
-----------------------
Attributes:
STA Airline Flight# Destination/Via Gate Status ETA
Values :
12:50 KingFisher 6E352 UK/Mumbai Terminal2 Landed 13:15| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 0of 0 votes
AnswersGiven a list of employees and their bosses as a CSV file , write a function that will print out a hierarchy tree of the employees.
- Trutgeek August 01, 2017 in United States for Phone Interview| Report Duplicate | Flag | PURGE
Amazon SDE-3 Data Structures - 0of 0 votes
AnswersDesign Distributed Web Crawler.
- hprem991 August 01, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 2of 2 votes
AnswersPhone Interview Amazon, Seattle
- aonecoding July 28, 2017 in United States
I. Get the sum of all prime numbers up to N. primeSum(N).
Follow-up: If primeSum(N) is frequently called, how to optimize it.
II. OODesign Parking Lot| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
Answers// Imagine you have an array of N messages which is consistently having new messages added to it.
- zak.abhishek July 24, 2017 in United States
// When you loop through the array, the messages are guaranteed to be ordered chronologically by timestamp.
// Write some code that loops through the array of messages and when a unique user_id has two messages within one second of each other, call a method too_fast that takes in two parameters, the first is the older message, the second is the newer message.
// In the message examples below we would expect to call the too_fast method with the first and third message, and then again with the third and fifth message.
// message example 1 = { "container_id": 123, "item_id": 456, "success": true, "timestamp": 1499351653, "user_id": 789 }
// message example 2 = { "container_id": 111, "item_id": 222, "success": false, "timestamp": 1499351654, "user_id": 333 }
// message example 3 = { "container_id": 444, "item_id": 555, "success": true, "timestamp": 1499351654, "user_id": 789 }
// message example 4 = { "container_id": 123, "item_id": 456, "success": true, "timestamp": 1499351655, "user_id": 999 }
// message example 5 = { "container_id": 123, "item_id": 456, "success": true, "timestamp": 1499351655, "user_id": 789 }
// Within the loop you can access attributes by using message.getContainerId() or message.getItemId for example, message.getTimestamp()| Report Duplicate | Flag | PURGE
Amazon - 0of 0 votes
Answerwrite bash code to determine if the first number in the string is greater than 1000
- ajay.raj July 22, 2017 in United States
STR="count ------- 43952 (1 rows)"| Report Duplicate | Flag | PURGE
Amazon Backend Developer - 0of 0 votes
AnswersI have a Amazon Phone interview for sr. business analyst They provided a collabedit link for the interview stating that we may ask Basic programming and SQL questions.
- HB July 21, 2017 in United States
Can someone having this experience from past help me understand what kind of questions I can expect. I honestly am a BA, PM professional with not a lot of exposure to coding or SQL. Some guidance will help me prepare better. Are the questions asked in SQL basic or quite intricate? Please advise| Report Duplicate | Flag | PURGE
Amazon - 0of 0 votes
AnswersThe memmove() function copies n bytes from memory area src to memory area dest. The memory areas may overlap: copying takes place as though the bytes in src are first copied into a temporary array that does not overlap src or dest, and the bytes are then copied from the temporary array to dest.
- jaya.ppatil July 21, 2017 in United States for AWS| Report Duplicate | Flag | PURGE
Amazon SDE-2 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 - 0of 0 votes
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 Software Engineer Trees and Graphs - 4of 4 votes
AnswersFind distance between any two nodes of binary tree and binary search tree.
- Raje July 19, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Trees and Graphs - 1of 1 vote
AnswersThere is a conference room. N people are joining the conference. You have the start time and end time of each of them visiting it. You are asked to determine the maximum number of people that can be inside the room.
- Raje July 17, 2017 in India
Example – Four people are visiting the conference
Person A B C D
Start (hour) 1 3 2 5
End (hour) 4 5 7 10
Answer will be – 3| Report Duplicate | Flag | PURGE
Amazon SDE1 dp , matrix ,recursion , flipkart - 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 string a and string b, find all the occurences of the anagrams of a in b.
- local.developer July 08, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon Senior Software Development Engineer Algorithm - 0of 0 votes
AnswersHow would you store very large numbers that can't be store in a regular Integer or BigInteger, and make calculations
- UCJava July 04, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Data Structures - 0of 0 votes
AnswersDesign an application for people to find a place near them where they can join a team to play their favorite sport. Exp. Soccer teams open to join that are scheduled to play at a certain time and place. The application would search for the available teams to join within certain area playing within some given time period,
- UCJava July 04, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Software Design