## Amazon Interview Questions

- 0of 0 votes

AnswersDesign a service to scan photos/videos for any malware

- novastorm123 October 16, 2019 in United States| Report Duplicate | Flag | PURGE

Amazon System Design - 0of 0 votes

AnswersWrite a method that merges a fixed number of streams containing an infinite sequence of monotonically increasing integers into an output stream of monotonically increasing integers. It is important to note that the input stream are infinite, so any solution based on the length of the streams would be considered incorrect.

Note that the question was given in the context of Java with the below code given as the base contract for the method.`public void merge(List<Stream> inputStreams, Stream outputStream) { // Implement me }`

This was also provided as the definition of "Stream" in this case, and not what is defined in java.util.stream.Stream.

- gr1ml0ck October 05, 2019 in United States`interface Stream { // Retrieves but does not remove the next item from the stream int peek(); // Retrieves and removes the next item from the stream. int poll(); // Puts an item into the stream void put(int i); }`

| Report Duplicate | Flag | PURGE

Amazon Solutions Engineer Algorithm - 0of 0 votes

AnswersWrite test cases for earring with diamond, gold clamp, diameter 13mm, width 4mm

- roman.khomitsky19 October 05, 2019 in United States| Report Duplicate | Flag | PURGE

Amazon Testing / Quality Assurance - 0of 0 votes

AnswersImplement union and intersection of two array(in a efficient way).

- dhruvjoshi43 October 04, 2019 in india for none

Additional information given by the interviewer was: elements of the two given array may be repeated but cannot be repeated in union and intersection array.| Report Duplicate | Flag | PURGE

Amazon Data Engineer test - 0of 0 votes

AnswersA co-ordinate plane was given. On each point (x, y) there are x+y number of apples on it. A person is standing on (0, 0) and he wants to buy a square plot having N number of apples inside it (including the periphery). Question was to return the value of perimeter of that square plot given N.

- 200MITTALGAUTAM August 26, 2019 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 - 0of 0 votes

AnswersDesign distributed crawling system which would be feeded a source url.

- neer.1304 August 09, 2019 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-3 Distributed Computing - 0of 0 votes

AnswersGiven 'n' servers each having millions of sorted integers. Find distributed median of all the 'n' servers.

- neer.1304 August 09, 2019 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-3 Distributed Computing - 1of 1 vote

AnswersGiven a binary matrix of 0 and 1 where we can move in 4 directions left, right, top, down and we can only pass through 1's. Find the shortest path from given source coordinate (a,b) to destination (m,n) given we can flip any one of the zero to one.

- neer.1304 August 09, 2019 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-3 Algorithm - 0of 0 votes

AnswersProgram for the given boolean matrix print size of matrix that forms X by 1s

- Rising star August 08, 2019 in United States

Input:

1 1 1

1 1 1

1 1 1

Otput:3

1 1

1

1 1

That form x and size is 3| Report Duplicate | Flag | PURGE

Amazon Backend Developer - 1of 1 vote

AnswerSuppose there is a function given to you that:

`def get_friends( person_id ) { /* returns friends of person */ }`

How you are now going to recommend friends to a person based on number of mutual friends? So, come up with the function:

- NoOne August 02, 2019 in India`def friend_reco( person_id, max_no_of_friends ){ }`

| Report Duplicate | Flag | PURGE

Amazon SDE-3 Algorithm - 0of 0 votes

AnswersGiven billions of Identity cards of the form :

`card : { my_id : "my id", "moms_id" : "mom id", "dad_id" : "dads id" }`

If one gives you two Person's id, how can you tell if these 2 persons are blood related.

So, write a function that is:

- NoOne August 02, 2019 in India`def is_blood_related( person_id_1, person_id_2 ) // go on..`

| Report Duplicate | Flag | PURGE

Amazon SDE-3 Algorithm - 0of 0 votes

AnswersDesign election voting system. Election would be country wide. System should be scalable, available and consistent.

- neer.1304 July 26, 2019 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Software Design - 0of 0 votes

AnswersGiven a string select two non-overlapping strings that are same and remove them. Perform this operation recursively till there are no desired strings.

- neer.1304 July 20, 2019 in United States

Print the number of possible substring after completing above operation.

Ex - abcc

Duplicate non-overlapping substring - abc

After removing abc from we are left with 1 substring abc.| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersIn a 2-D matrix of m*n select m-1 elements from each row such that that the resulting sum is minimum and each column is selected atleast once.

- neer.1304 July 20, 2019 in United States

Ex -

2 3 5

3 2 5

4 4 7

Selecting (2,3) from 1st row, (2,5) from 2nd row and (4,4) from 3rd row would result in minimum sum of 20| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersFind LCA for list of nodes of a tree

- neer.1304 July 17, 2019 in United States

Function defined as below -

TreeNode findLCA(TreeNode root, List<TreeNode> nodes)| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven two numbers m and n. Find all numbers between these two numbers such that difference between adjacent digit is 1

- neer.1304 July 01, 2019 in United States

For ex m =0 n =22

O/p - 0,1,2,3,4,5,6,7,8,9,10,12,21| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 1of 1 vote

AnswerGet the sum of all prime numbers up to N. primeSum(N).

- acoding167 July 01, 2019 in United States

Follow-up: If primeSum(N) is frequently called, how to optimize it.| Report Duplicate | Flag | PURGE

Amazon - 0of 0 votes

AnswersIn a garden, there are several apples trees planted in a grid format. Each point (i,j) in the grid has |i| + |j| apples.

Allie can buy a square plot centred at (0,0). Find the minimum perimeter of the plot (1 unit having length = 1) such that she can collect at

least X apples. All plants on the perimeter of the plot are also included.

Sample:

- bertram_gilfoyle June 27, 2019 in India`Input = 1 Output = 8 input = 11 Output = 8 Input = 13 Output = 16`

| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 0of 0 votes

AnswersYou are required to collect N numbers from a bag. Initially, the bag is empty. Whenever you put a number X in the bag, then the owner of the bag asks the question.

- Sameer June 21, 2019 in United States

The questions are as follows:

. What is the greatest integer that is smaller than X and present inside the bag?

. What is the smallest number that is greater than X and present inside the bag?

If you answer both the questions correctly, then you can put X inside the bag. Your task is to answers the questions that are asked by the owner of the bag. If no such numbers exist in the bag print -1.

Example:

5 (Number of elements in the bag)

1

4

2

3

7

output:

-1 -1

1 -1

1 4

2 4

4 -1| Report Duplicate | Flag | PURGE

Amazon Java Developer Data Structures - 0of 2 votes

AnswersGiven an array of integers A. calculate the sum of A[i] %A[j] for all possible i,j pair. return sum%(10^9+7) as an output solve this problem on o(n).

- Dhioyt June 19, 2019 in India

input :-

A=[1,2,3]

Output:-

5

Explanation:-

(1%1)+(1%2)+(1%3)+(2%1)+(2%2)+(2%3)+(3%1)+(3%2)+(3%3)| Report Duplicate | Flag | PURGE

Amazon SDE1 Algorithm - 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

Answers"Good Range"

- Mit25 May 29, 2019 in United States

There is a number space given from 1 to N. And there are M queries followed by that. In each query, we were given a number between 1 to N (both inclusive). We add these number one by one into a set.

Good range: A range in which there is exactly one element present from the set.

For each query, we need to find the good ranges. We need to return the sum of boundry of all good ranges.

Input:

First line will take two integer for input N and M.

Then following M lines would be numbers between 1 and N (both inclusive).

Output:

Following M lines contains sum of boudaries of good ranges.

Note:

Range can consist of single element and represented as (x-x) where boundary sum will be x+x.

Example:

Input:

10 4

2

5

7

9

Output:

11

18

30

46

Explaination:

step-1) set: 2

good range: (1-10)

sum: 1+10=11

step-2) set: 2 5

good range: (1-4), (3-10)

sum: 1+4+3+10=18

step-3) set: 2 5 7

good range: (1-4), (3-6), (6-10)

sum: 1+4+3+6+6+10=30

step-4) set: 2 5 7 9

good range: (1-4), (3-6), (6-8), (8-10)

sum: 1+4+3+6+6+8+8+10=46| Report Duplicate | Flag | PURGE

Amazon SDE1 Coding - 0of 0 votes

AnswerDesign a system to upload images with tags. The tags should be searchable and search should return images linked to those tags.

- arnold086 May 25, 2019 in India| Report Duplicate | Flag | PURGE

Amazon SDE-2 System Design - 2of 2 votes

AnswersGive m balls and n bins. Find out how many ways to assign balls to bins. Notice the buckets has no order. Like (1,2,3) and (3,2,1) are considered the same.

- acoding167 May 16, 2019 in United States

eg, m = 3, n = 2, return 2. (1, 2) and (3, 0)| Report Duplicate | Flag | PURGE

Amazon Software Engineer - 0of 0 votes

AnswerGiven items as Shirt, Trouser, Shoes, Tie, Belt, Shocks, and dependencies as -

- alisonlee659 May 15, 2019 in United States

Tie can be worn after Shirt

Belt can be worn after Shirt and Trouser

Shocks can be worn after Trouser

Shoes can be worn after Shocks

Find various orders in which the activity of wearing clothes can be completed.| Report Duplicate | Flag | PURGE

Amazon Software Engineer - 0of 0 votes

AnswerI dont remember the exact problem anymore. but the problem's solution included going through an array and at every step taking 2 minimum element and adding the result. this also includes the result itself.

- Desi May 13, 2019 in United States for Robotics

so lets say for following array:

2,54,4,10,1,7

you first take 1 and 2 and add

then add the result 3 to the array

so now your array looks like :

3,54,4,10,7

then you take 3 and 4 and add them and add result back

I basically used a heap where i take two mins and add them and add the result back to heap.

I have give amazon online test twice in last 8 months and both the times the first question was about heaps and second something about finding shorted path in a grid between two cells| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersThe problem was very similar to the problem from geeksforgeeks:

- Desi May 13, 2019 in United States for Robotics

Shortest distance between two cells in a matrix or grid

Given a matrix of N*M order. Find the shortest distance from a source cell to a destination cell, traversing through limited cells only. Also you can move only up, down, left and right. If found output the distance else -1.

instead of source and destination, they asked for robot to be able to get rid of obstacle at a certain cell.

I have give amazon online test twice in last 8 months and both the times the first question was about heaps and second something about finding shorted path in a grid between two cells| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersDesign amazon online book store.

- Desi May 13, 2019 in United States for Robotics| Report Duplicate | Flag | PURGE

Amazon SDE-2 System Design - 0of 0 votes

AnswersI am given jobs with starttime and end time and we unlimited VMs. at any point a VM can only take one job. so bascially I had to find overlapping jobs and assign them to different machines and those that are not overlapping could be assigned to same machines. The tricky part was when there are two different overlaps and they could be assigned to 2 machines instead of all overlapping jobs being assigned to different machines.The method should return minimum number of VMs used to finish all jobs.

- Desi May 13, 2019 in United States for Robotics

I mentioned sorting the jobs based on start time. and then returning number_of_overlapping jobs +1. but again in some cases if there are two different overlaps which could be assigned to two machines then we need to take care of that.| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersExpression tree evaluation and also write the class for the node and tree itself. (just basic structure like node and data)

- Desi May 13, 2019 in United States for Robotics| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window