## Amazon Interview Questions

- 0of 0 votes
Given two sorted arrays A and B that may have repeated elements. Form a new sorted array C that contains the elements of A and B [Condition : You are not allowed to merge the two arrays and then sort. ]

- 0of 0 votes
Given an array , find the element (say X) that has all the elements less that it to its left side and all the elements greater to it on its right side.

The left and right elements of X need not be in sorted form.

- 0of 0 votes
Find the maximum consecutive 1's in an array of 0's and 1's.

Example:

a) 00110001001110 - Output :3 [Max num of consecutive 1's is 3]

b) 1000010001 - Output :1 [Max num of consecutive 1's is 1]

- 0of 0 votes
Write test cases on Whatsapp group chat

- 0of 0 votes
You are given an array of integers. Find the minimum difference between two prime numbers(Positive or negative) in the array when present with minimum time complexity and provide the test data to test the this code.

- 0of 0 votes
Give a large multi MB byte file in memory, a system handles delete requests for segments typically of the order of bytes. The system has a constraint that individual purge requests of byte segments are expensive, so that the no. of purges are a minimum.

Eg. a 5 MB file receives delete requests for offsets (1, 100), (250, 550),(1000, 1200), (400, 600), (800, 900), (1100, 1150)

Effective delete requests - (1, 100) , (250, 600), (800, 900), (1000, 1200)

The users of the system always go by the absolute byte ordering of the file. Eg. if byte 1 is deleted, the users of the system will reference the actual byte 2 as byte 2.

What data structure would you use to store these intervals such that the following operations are efficient 1. Looking up an interval 2. Inserting a new interval that has no overlap with existing ones 3. Inserting a new interval that has partial overlaps with existing intervals. This would involve collapsing the existing intervals with the new interval to form a single large interval. Eg. Interval cache: {(1, 100), (250, 550), (1000, 1200)} , new interval : (400, 700) -> Interval cache: {(1,100), (250, 700), (1000, 1200)}

- 0of 0 votes
How to verify the string which contains alpha-bates,parenthesis and signglle/double quote

Ex: AB(CD{"GH"}) is valid

"A()B' is invalid

- 0of 0 votes
Implement Java Set using TDD

- 0of 0 votes
Given an mXn Sorted matrix and a value X. Every row is sorted and first number of every row is greater than last number of previous row Find the value X in most efficient way.

- 0of 0 votes
Given a Binary tree and value X. Find X in the tree and return its parent

X:

10

4 3

5 7 9 8

If X = 7, return 4

- 0of 0 votes
Remove 3 consecutive duplicates from string.

INPUT:aabbbaccddddc

OUTPUT:cdc

- 0of 0 votes
Randomly select one of the weighted items from a linked list. (you may only go through the list once)

e.g.

weight 1.6 -> weight 0.2-> ... -> weight 3.4

randomly select one item based on the weight. The higher the weight is, the more likely to be selected

- 0of 0 votes
Given two strings needle and haywards that contains ASCII characters,write an algorithm to output a list of 0-based indices of the occurances of all anagrams of needle in haystacks

- 0of 0 votes
You are given an array of integers(with all valid input) You have to write a function which will produce another array, where the value in each index of the array will be the product of all values in the given array accept that index.

Example

Array 1: 1 2 3 4 5

Array 2: 120 60 40 30 24.

Come up with a solution of O(n^2) can you improve it?

- 1of 1 vote
Print the longest path from root to leaf in a Binary tree (Basically the nodes that lie on the height path).

- 1of 1 vote
down vote

favorite

Consider the following series:

A := 1

B := A*2 + 2

C := B*2 + 3 and so on...

Write a program that:

-outputs the number corresponding to a given letter;

-given a string of letters like 'GREP', computes the sum of the numbers corresponding to all the letters in the string (i.e., G + R + E + P), as given by the above series; and

-given a large number (that would fit into a standard 32-bit integer), finds the shortest string of letters corresponding to it. You may use a greedy approach for the last part. Compute the values of the numbers corresponding to letters as and when required and DO NOT pre-compute beforehand and store them in a data structure.

- 0of 0 votes
Write test conditions and test data to test a app which has login and signup screen on a mobile app and once you click on signup or login it takes you to a website to fill the remaining details(for sign up) or to perform any activities post login. The screens were provided with all the fields.

- 0of 0 votes
Write a code for reversing letters of string in java.

- 0of 0 votes
Write code for implementing Binary Search algorithm.

- 0of 0 votes
You are part of a team that develops push notifications on an app (android/iOS). The push notifications are sent out for ads published by a marketing team from a data source that they own. Come up with the test plan/cases

- 0of 0 votes
With the best time complexity, please come up with a code to find the minimum delta of two elements from two different arrays of integers of different sizes - a[-3, 1, 999], b[-1, 2, 3]

Edit: Please dont forget the min delta can also be from b-a not just a-b

- 0of 0 votes
Design an ATM machine system..

- 1of 1 vote
given a stream of natural numbers ,

and a array J contains integers in increasing orders

operations performed J = [2,3,4]

1 2 3 4 5 6 7 8 9 10…………..27....100...1111

first operation

J[0] = 2 => remove every 2nd integer

now the stream is

1 3 5 7 … 27

J[1] = 3

remove every 3rd

stream is now

1 3 7 …

3rd

given a natural number n , find if it will survive given J, or at what index it will

die.

- 1of 1 vote
Design OO food delivery app catering to use cases -

1) User can search different restaurant

2) User can select a restaurant

3) User sees a menu

4) Restaurant can change the menu any time

5) User adds an item from menu

6) User orders the food

7) User can track the order in real time

8) User can cancel the order

9) User pays for the order

- 0of 0 votes
Design food delivery app (OO design). Cater to use cases like search for different restaurants, selecting a restaurant, select an item from menu, menu can be updated in real time by restaurant, order the food, customer keeps track of the order in real time, payment for the order, cancel the order etc.

- 0of 0 votes
Design Uber low level OO design. Cater to use cases like search for a ride, different category of rides, select a ride, registration for a user and driver, paying for ride etc.

- -2of 2 votes
Find sum of n elements after kth smallest element in BST. Tree is very large, you are not allowed to traverse the tree.

- 0of 0 votes
There are Items[I1, I2, I3, I4] available in warehouses [W1, W2, W3, W4, W5] and serviceable by multiple partners with some shipping cost.

I1 available in W1

– serviceable by these partners S1[0.75 -shipping cost/selection cost], S2 [0.74], S3 [0.70]

available in W2

– serviceable by these partners S1[0.75], S2 [0.74], S3 [0.70]

available in W3

– serviceable by these partners S1[0.80], S2 [0.74], S3 [0.70]

I2 available in W4

– serviceable by these partners S2[0.85], S3 [0.94], S4[0.30]

available in W3

– serviceable by these partners S1[0.80], S2 [0.74], S3 [0.70]

I3 available in W1

– serviceable by these partners S1[0.85], S2 [0.55], S3 [0.70]

available in W2

– serviceable by these partners S1[0.80], S2 [0.54], S3 [0.70]

I4 available in W4

– serviceable by these partners S2 [0.74], S3 [0.70], S4[0.30]

available in W2

– serviceable by these partners S1[0.85], S2 [0.80], S3 [0.70]

available in W3

– serviceable by these partners S1[0.80], S2 [0.74], S3 [0.70]

You have to optimally select the items so that total cost will be minimum.

Ex: I can make a shipment from I1, I2, I4 fulfilled by W3 which will cost:

for partner S1: 2.40

for partner S2: 2.22

for partner S3: 2.10

Another Shipment I3 fulfilled by W2 which will cost: S2 [0.54]

Total cost: 2.10+0.54 = 2.64 with Shipment SH1 {I1,I2,I4} By S3 and SH2 {I3} by S2

Another possible way

I1, I3, I4 serviceable by W2 by Provider S2 : 2.08

I2 serviceable by W4 by S4: 0.30

Total cost: 2.38

So the shipments with minimum cost can be delivered/selected.

Write a program for the same to get optimum minimum cost for the number of shipments can be delivered from warehouses with shipping cost?

“If you ship multiple items in single packet, then the cost will be minimum. Assume Shipment Provider charges per packet and not on the weight and packing charges will be minimum. Idea is to consolidate/aggregate as many items as possible to one location so that packaging cost is minimum and on top of that you should consider warehouse selection cost.”

- 0of 0 votes
Q. Given an array of numbers. Print all the pairs (2) of numbers in the array if the sum of those numbers is also present in the array. Write in C

- 0of 0 votes
Design and implement traffic control system, also include pedestrian signal management as part of this solution.