## Amazon Interview Questions

- 0of 0 votes
Link all the level order nodes to makes a linked list with the first node of each level acting as the root of that linklist.

10

/ \

6 17

/ / \

4 14 19

So the Linklist will be

10->null

6->17->null

4->14->19->null

- 0of 0 votes
You have three containers, small, medium and large. Passenger comes in, checkin the luggage. You have to store the baggage in the appropriate container and generate a unique token number. Then passenger should get back the bag using the same token number. Trick was if small container is full store in medium if available or large. Now if the large bag comes in and there is now a empty space in small, than move the small bag back to small & store the large bag. How to generate the unique token number and move the baagage internally without changing the token number?

Lookup should be in constant time complexity and insertion in minimum complexity.

- 0of 0 votes
Scenario : Multi Seller E-commerce Website

Given a list of products in a customer basket find the minimum number of seller required to deliver his order,so as to optimise shipping part.

Assuming you have already have below data

Customer orders products : P1,P2,P3,P4,P5,P6

Products and seller mapping

P1 = [1,2,3,4]

P2=[2,4,5,6]

where 1,2,3 etc denotes seller_ids.

p1

- 0of 0 votes
If I was a marketer for a large company, tell me how I can increase the number of likes I have on my Facebook business page to 5 million?

- 0of 0 votes
Your are given two strings str1 and str2, you have to generate another unique string str3, which can only generated by these two string str1 and str2, no other string can generate that string str3. Some later point you have to retrieve back those two string str1 and str2 form that unique string str3.

- 0of 0 votes
You are given an array, you have to replace each element of the array with product of the rest element. Example: {1,2,3}==> {6,3,2}

- 0of 0 votes
Suppose you have an array with infinite numbers, which is sorted and there may be duplicates. Find the occurrence of a number.

- 0of 0 votes
How will implement an auto complete feature? Eg: if you type clo it shows clothes etc

- 0of 0 votes
Suppose there are 2 streams, which has infinite value and write a method that returns a stream that would be a combination of both the streams in a sorted form

- 0of 0 votes
Write printf method.

- 1of 1 vote
Which is best Merge Sort or QuickSort?

Why and How?

- 0of 0 votes
Amazon wants to implement a new backup system, in which files are stored into data tapes. This new system must follow the following 2 rules:

1. Never place more than two files on the same tape.

2. Files cannot be split across multiple tapes.

It's guaranteed that all tapes have the same size and that they will always be able to store the largest file.

Every time this process is executed, we already know the size of each file, and the capacity of the tapes. Having that in mind, we want to design a system that is able to count how many tapes will be required to store the backup in the most efficient way.

The parameter of your function will be a structure that will contain the file sizes and the capacity of the tapes. You must return the minimum amount of tapes required to store the files.

Example:

Input: Tape Size = 100; Files: 70, 10, 20

Output: 2

- 0of 0 votes
Find the first word in a stream in which it is not repeated in the rest of the stream. Please note that you are being provided a stream as a source for the characters. The stream is guaranteed to eventually terminate (i.e. return false from a call to the hasNext() method), though it could be very long. You will access this stream through the provided interface methods. A call to hasNext() will return whether the stream contains any more characters to process. A call to getNext() will return the next character to be processed in the stream. It is not possible to restart the stream.

Example:

Input: The angry dog was red. And the cat was also angry.

Output: dog

In this example, the word ‘dog’ is the first word in the stream in which it is not repeated in the stream.

- 0of 0 votes
For a given matrix, find the maximum product of k elements. The elements can be formed from continuous 4 elements horizontally, vertically or diagonally. Eg: For k= 4, the maximum product is (6*4*7*9) from the last column,

1 2 0 -1 4

3 1 2 4 6

0 2 3 1 4

1 3 2 0 7

2 1 3 2 9

- 0of 0 votes
(Variant of Children-Sum Problem better than O(n^2))

Given a tree, implement a function which replaces a node’s value with the sum of all its childrens’ value, considering only those children whose value is less than than the main node’s value.

Eg: input = 60->50->80->40 , output = 90->40->40->0

- 0of 0 votes
Given a function rev(int i) which reverses the segment of array ar[] from 0-i, Implement a function sort() using rev().

- 0of 0 votes
Find if a given number can be expressed in the form of p^q, where p and q are integers

- 0of 0 votes
Find all palindromes in a given string. Single letters are also considered as palindromes.

- 0of 0 votes
Given a number A, find the smallest number which has only 1s and 0s as its digits which divisible by the number A. For example: if the given number A is 4, the smallest number with 1s and 0s is which is divisible by 4 is 100.

- 0of 0 votes
how will you start debugging a issue in Newspaper app

- 0of 0 votes
How would a test a Online Editor?

- 0of 0 votes
How would you start debugging a Newspaper app (Web, Mobile, Desktop)

- 0of 0 votes
How would you test a Online Editor?

- 0of 0 votes
How do you debug RSS Feed Ticker app

- 0of 0 votes
Given a list of email list, find all email addresses that are in all the email list.

- 0of 0 votes
You're the guard of a prison, you want to keep an eye on the most dangerous prisoner. Each prisoner has a danger rank of his own and a group of friends (prisoners, who also have danger ranks). The guard has a list of prisoners with their corresponding danger ranks and he also has a list of the friends of each of the prisoners in the prison.

The danger rank is computed as follows: Prisoner 1 has a danger value of 5, his friends are Prisoner 2 and Prisoner 5, who have danger values of 3 and 4 respectively. So the danger value of Prisoner 1 is 5+3+4 = 12.

There could be any number of prisoners. Whichever prisoner has the highest value is the most dangerous(computed using the above method).

Friendship can be assumed to be symmetric.

Come up with an efficient algorithm to find the most dangerous prisoner?

- 1of 1 vote
{{

There are 3 machines M1, M2 and M3. Each machine is 90% full of its capacity with integers. Now you have to sort all the integers combined and then store the first 1/3rd in M1, second 1/3rd in M2 and last 1/3rd in M3.

Your objective is to minimize the number of sort operations and number of data transfer operations.

Each sort operation/data transfer operation is counted as 1 irrespective of the count of values that are being sorted/transferred.

}}

- 0of 0 votes
Entry in the log file is like this:

User 1 visited Page 4

User 3 visited Page 2

User 7 visited Page 9

.

.

.

Design an efficient data structure which supports queries like the following:

Which page was visited by exactly 2 users in day?

Which page was visited by only one user exactly 2 times in a day?

Which page was visited by ‘User 3? more than 5 times in a day?

- 0of 0 votes
Design a system for finding the costliest element always whenever we pick up an element from a box.(concept of Max Heap)

- 0of 0 votes
Entry in the log file is like this:

User 1 visited Page 4

User 3 visited Page 2

User 7 visited Page 9

.

.

.

Design an efficient data structure which supports queries like the following:

Which page was visited by exactly 2 users in day?

Which page was visited by only one user exactly 2 times in a day?

Which page was visited by ‘User 3? more than 5 times in a day?