## Amazon Interview Questions

- 0of 0 votes
Design a restaurant reservation system - You need to design everything from scratch - Identify actors in the system, identify what all data should be stored in persistence storage (and why). How would you make your design scalable?

- 0of 0 votes
Design a data structure which could perform the following operations in O(1):

- Insert(), Delete(), Search(), getRandom()

getRandom() should pick a "random" element from your data structure, and should not be predictable (for instance always picking the "first" element from your DS)

- 0of 0 votes
You are given a stream of incoming strings. Design a data structure, which at any instant, could tell the 100 most repeated words in constant time.

- 0of 0 votes
Given a very large array of sorted integers, find the number of times a particular integer has been repeated in the array. Required complexity : O(logN)

- 0of 0 votes
At regular interval, we are receiving data (Price,Quantity). We need to find Most Sold Price(MSP). Need to design the solution to print the current MSP with total Qty of that price, every time a set of price and its quantity sold is provided as input.

`Time Price Qty MSP(Total Qty) 11:01AM $10.01 100 $10.01(100) 11:03AM $11.01 200 $11.01(200) 11:04AM $12.81 150 $11.01(200) 11:06AM $10.01 210 $10.01(310) 11:07AM $10.01 180 $10.01(490) 11:08AM $12.81 400 $12.81(550) 11:09AM $11.01 200 $12.81(550)`

In the interview, I wrote a solution using priority queue where each element of the priority queue is a tuple consisting of price and quantity. The priority queue arranges itself based on the quantity value of each tuple. When new value comes we access the tuple having the particular price, retrieve its quantity. Delete this tuple and insert a new tuple with the same price and updated quantity.

The interviewer was not satisfied with the solution and commented this is not how a large scale application will be build which is running throughout the day.

- 0of 0 votes
Given 2D Array of only 0s and 1s, Find the row which gives max decimal value.

Input: int array[3][3] = {{0,1,0,}{1,1,0},{1,0,1}};

Output : 2(second row)...decimal value is 6

- 0of 0 votes
Write a code to find out the median in an array of integers (array could have even number of elements or odd number of elements)

(To update some hint at the end from the interviewer : he would look for a binary tree and find out some way to balance the tree and than obtain the median)

- 0of 0 votes
Given employee information in an organisation in the formal - emp_id,firstname,lastname,reports_to in the following way

{

string[] Values = new[] { "Mc Grill,Mc,Grill,Karmon","Karmon,Zech,Karmon,Joe","Mithun,Try,Mithun,Joe","Joe,Top,Joe,","Zara,Aman,Zara,Mc Grill","Fizzy,Dude,Fizzy,Mc Grill"};

}

Print the information from the top to bottom level in the way

1) Top Joe

2) Try Mithun

2) Zech Karmon

3) Mc Grill

4)Aman Zara

4) Dude Fizzy

- 0of 0 votes
Given a group of no.s you need to arrange them in a such a way that they result into maximum no.

The input no. can be of more than 1 digit, don't change no. digits order.

- 2of 2 votes
How do we achieve (google news) personalization.

- 0of 0 votes
how to find all paths of a graph?

hi ,

i have a directed graph as an input and i want to find in that graph subGraphs that fit to some path

for example : i have the following graph 1[E] ->2[E] ->3[M]->4[E]->5[M]->6[M]->7[E]->8[M] .and i have the path E->M->E

then the program output should be the subGraph 2->3->4

note that the solution should be implemented as ADJ Matrix

the Graph is directed DAG

the program should be with C language

- 0of 2 votes
Given a 1D array, implement function Sum(x1,x2) where x1 and x2 are indices of array. Find sum of all elements in between the given indices inclusive of them. Do in Time complexity of O(1)

- 0of 0 votes
Given a system in which a musician is selling his CD's. User can enter how many CD"s he/she wants. Enter his/her address detail and click on next. The cost for the number of CD's, tax for the order, Shipping cost for the order and Total values are displayed. User enter the credit card / debit card details. Click on next. If the transaction successful/unsuccessful display the message accordingly. There is a bank web service which reads card information and a response is sent based on if it is a valid card or not. A database which stores all the information about user orders and their status. An admin portal which accesses the database to edit/update on user order status and user information. Test the complete system.

- 1of 1 vote
Test Amazon Website

Functionalities: Two categories with 100 products each, Buying a product, Customer information, Order tracking

- 0of 0 votes
Explain the complete automation design and What have you contributed in the automation framework

- 0of 0 votes
How do you test search functionality of Amazon. Include category based searches as well. What tests you will automate and what tests you will not automate

- 1of 1 vote
Given a string and two words which are present in the string, find the minimum distance between the words

Eg: "the brown qucik frog quick the", "the" "quick" O/P -> 1

"the quick the brown quick brown the frog", "the" "the" O/P -> 2

- 1of 1 vote
How to find if a given expression is a valid arithmetic expression?

Eg:(())()) - Invalid expression, (()()) - Valid expression

- 0of 0 votes
Find the first and last occurrence of a number in a sorted array of integers

For Example: int[] a = {1,2,3,4,5,5,7,8}

- 0of 0 votes
The Echo device light's up when a question is asked, but does not answer the question. Troubleshoot the scenario

- 0of 0 votes
Write test cases for an analog watch

- 1of 1 vote
Given a linkedlist, write an algorithm to divide the linkedlist into two linkedlists, the first contains the Fibonacci numbers in the list and the second contains the non-Fibonacci numbers.

Test the algorithm after developing the code

- 0of 0 votes
Input argument of a method is a list of char array. The method have to print all the possible combination of input char(s)...For example if the input argument has ['A','B','C','D'] the output should be A,B,C,AB,AC,AD,BC,BD,CD,ABC,ACD,BCD,ABCD

- 0of 0 votes
Given a list of sorted arrays, like List<int[]>. Prepare and return a single sorted list.

- 1of 1 vote
An employee class has id, name and a vector of employees who reports him. Given two employees find the common manager of them.CEO pointer is provided.

- 0of 0 votes
Given two Binary Trees (not BST). Each node of both trees has an integer value. Validate whether both trees have the same integers, there could be repetitive integers.

ex-

Tree1:

5

1 6

5 4 3 6

Tree2:

1

3 4

6 5

have identical integers.

- 1of 1 vote
Given a string which may contain parenthesis. We must verify the validity of the string.

ex-

1) "<ad675+-fkmfd>" is a valid string

2) "<[((kskfhdbh7)" is invalid

3) "[<<((shfs8))>>]" is valid

Extension to the question -

Suppose you had a hash table that told you how a parenthesis starts and how it ends as a key value pair, how would you then validate the string.

ex - <key,value> = < '(' , ')' > indicates '(' is a start parenthesis and ')' should be the end of that paranthesis.

<'A','&'> indicates that 'A' is a start parenthesis and '&' is the end parenthesis.

Note: Validity means a parenthesis that starts, must end.

- 2of 2 votes
Find the largest substring palindrome in a given string.

ex: input: abbac output: abba

Solution: Use Hashmap

- 0of 0 votes
Given a grid of m*n size. Each block in grid has some amount of gold.

We start from first column of the grid(any row) and we can move in 3 direction - right, right-up and right-down.

What is the maximum amount of gold we can collect from the grid.

- 1of 1 vote
Print first and last node of all the levels of a tree.

Ex if tree is -

root->data = 1

root->left->data = 2

root->right->data = 3

root->left->right->data = 4

root->right->right->data = 6

root->right->left->data = 5

root->right->left->left->data = 7

root->right->left->left->right->data = 8

Output - 1 2 3 4 6 7 8