## Amazon Interview Questions

- 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 - 0of 0 votes

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 - 0of 0 votes

AnswersLRU cache. Basically started off with how would I store values and get them from memory for faster access. So I mentioned HashMap. and then interviewer added more info about deleting least recently used element.

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

Amazon SDE-2 Algorithm - 2of 2 votes

AnswersVerify if S2 = {5,8,2} is a subset of S1 = {1,5,4,6,8,2} and S3 = {5,8,2,7} is not a subset of S1.

- hadeebataj May 10, 2019 in India| Report Duplicate | Flag | PURGE

Amazon Quality Assurance Engineer String Manipulation - 2of 2 votes

AnswersVerify if the given strings is an anagram.

- hadeebataj May 10, 2019 in India

Ex: Str1: LISTEN, Srt2: SILENT.

Alter the program if there is more than one letter that repeats in any one of the strings.| Report Duplicate | Flag | PURGE

Amazon Quality Assurance Engineer String Manipulation - 2of 2 votes

AnswersWrite a code to return a value 'True' if the number '1' throughout the array appears consecutively. Ex: S = {1,1,1,0,0,3,4}.

- hadeebataj May 10, 2019 in India

Else, return 'False' if the array does not have the given number (char = '1' in this case) in the consecutive order. Ex: S = {1,1,0,0,1,3,4}| Report Duplicate | Flag | PURGE

Amazon Quality Assurance Engineer Arrays - 1of 1 vote

AnswersGiven a List of Nodes, with each Node having an ID and a parent ID, determine whether the List is given in preorder.

- acoding167 May 07, 2019 in United States| Report Duplicate | Flag | PURGE

Amazon Software Engineer

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

Open Chat in New Window