## Amazon Interview Questions

- 2of 2 votes

AnswersDesign a Netflix type system. Start from HLD to LLD.

- neer.1304 August 31, 2017 in United States

Consider requirements like search, video serving, authentication, security, serving multi quality video.| Report Duplicate | Flag | PURGE

Amazon SDE-3 design - 0of 0 votes

AnswersGiven an array of integers. We need to answer two types of queries point update and range sum in minimum time.

- neer.1304 August 31, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-3 Algorithm - 0of 0 votes

AnswersPut the given random pointers in linkedlist to point to next greater node such that if you transverse the list using random pointers, list become sorted. duplicates are allowed.

- neer.1304 August 31, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-3 Algorithm - 1of 1 vote

AnswersFind third highest value in a binary tree

- neer.1304 August 31, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-3 Algorithm - 0of 0 votes

AnswersYou are given a set of N horizontal lines which are connected by equal number of vertical lines to form squares of size 1x1. Now some segments are removed. You need to count the number of squares of all sizes (1x1, 2x2, ..., NxN) with all sides present.

- imunique August 30, 2017 in India

Image : https://he-s3.s3.amazonaws.com/media/uploads/1ce3516.png

In the above example you see four horizontal and vertical lines and few missing segments. Now you need to count the number of squares of all sizes with all sides.

Input :

First line is a positive integer N, number of horizontal and vertical lines.

Second line is positive integer M, number of segments removed.

Then there are m lines, each containing V,i,j or H,i,j where i and j are positive integers. H,i,j indicates a horizontal missing segment in the ith horizontal line between the jth and (j+1)th point on the line. V,i,j represents a gap in ith vertical line between the jth and (j+1)th point on the line.

Output :

Is the total number of squares in the figure with all sides along the remaining lines in the figure.

Sample Input :

4

4

H,2,1

H,3,1

V,2,2

V,2,3

Output :

5

Explanation : Here in this figure we have 4 squares of size 1x1 and 1 square of size 3x3, hence total is 5.| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm Data Structures Dynamic Programming Online Test Problem Solving - 0of 0 votes

AnswersGiven data of millions of people, (name, age, M/F etc.) Develop an API that will have age range as input and yield the count of people under this range as output.

- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 1of 1 vote

AnswerA T20 match is going on. You’re in Team B. First innings is over, they have scored “teamARuns” runs. Your team has scored “teamBRuns” runs at the end of “balls” balls. A ball can have multiple possibilities like [0, 1, 2, 3, 4, 5, 6, Wicket, No ball, Wide ball]. What is the probability that your team (Team B) will win?

- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven a dictionary of words and a string pattern. Output the count of words that match the string pattern in the dictionary.

- neer.1304 August 30, 2017 in United States

Eg. Dictionary: [cat, rat, mat, apple, boy, bat]

String pattern: ?at

Output: 4 (because cat, rat, mat, bat matches the string pattern)| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven any two nodes in a binary tree, find the path from 1st node to another, and tell if the path is a straight line, or there are turns on the line, find number of turns.

- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersFind the maximum difference between any combination of child and parent node in a given binary tree. Here child node can be any level below parent node, but should be in the same sub tree starting from parent node.

- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 1of 1 vote

AnswersDesign Truecaller. Both HLD and LLD.

- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 design - 0of 0 votes

AnswersGiven a chessboard, find minimum number of moves for a knight to reach from source to destination.

- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswerGiven a fully connected graph with n nodes and corresponding values. One node can interact with other node at a time, to replace/ignore/add its value to other node’s value. Assuming this operation takes 1 unit of time, how much time would it take for all the nodes to have value equal to sum of all the nodes.

- neer.1304 August 30, 2017 in United States

Examples : Given a graph with values {1,2,3,4}, find total time it takes, such that all nodes have value as 10.| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 1of 1 vote

AnswersGiven a Singly Linked list, Update the second half of the list such that n-th element becomes sum(1st + nth) element, (n-1)st element becomes sum(2nd + n-1st) element and so on. Eg: 2->3->4->5->6 => 2->3->(4+4)->(5+3)->(6+2)

- neer.1304 August 30, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven an Infinite stream of strings as AAAAABBBCCDDDEEE… How will you arrange characters so that string become unique without duplicates .

- neer.1304 August 30, 2017 in United States

Return true if it is possible to arrange else return -1.

Ex . AAABBCCDEF – O/p ABABCDCEF : Possible . AAAAAAAAAAAAAAAAAAAAAAB : Not possible| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven an array of integers, replace every number with the next higher number to its right. If a number can’t be replaced, we leave it as-it is.

- neer.1304 August 30, 2017 in United States

For example, the list: 5, 2, 1, 4, 6, 7 needs to be changed to 6, 4, 4, 6, 7, 7.| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven two unsorted arrays A, B. They can contain duplicates. For each element in A count elements less than or equal to it in array B

- neer.1304 August 30, 2017 in United States

Examples:

Input : A = [1, 2, 3, 4, 7, 9]

B = [0, 1, 2, 1, 1, 4]

Output : [4, 5, 5, 6, 6, 6]| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersWrite a logic to print the elements of 2D matrix in a spiral way?

- explorer August 25, 2017 in United States

for eg if int[][] matrix = {{1,2,3,4}{5.6,7,8}{9, 10, 11,12}};

The output should be 1 2 3 4 8 12 11 10 9 5 6 7

The interviewer asked me to implement a recursive algorithm.| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer Arrays - 1of 1 vote

AnswersGiven a continuous stream of numbers, write a logic to find k maximum numbers at any given point of time where k is fixed?

- explorer August 25, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer Algorithm - 0of 0 votes

AnswerGiven some set of points in each quadrant of a 2D graph and two edges at a fixed angle, find the minimum angle at which the edges would cover maximum points between them?

- explorer August 25, 2017 in United States

I was confused on how to start and interviewer hinted me to consider each point at some angle from base (say 0) and continue finding all points which lies within the fixed angle.| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer Algorithm - 0of 0 votes

AnswersGiven a binary tree, how do you serialize and deserialize. Remember it is not BST it is a general binary tree which can also have duplicate elements.

- agrawal.arpit35 August 22, 2017 in India| Report Duplicate | Flag | PURGE

Amazon SDE1 - 0of 0 votes

AnswersFind the largest repeating sub-string in a string.

- Constantine August 22, 2017 in United States

ex: banana

ans is: ana| Report Duplicate | Flag | PURGE

Amazon SDE1 - 1of 1 vote

AnswersYou are given a log file with the bandwidth information of users in several lines.

- dj16 August 19, 2017 in United States

Bandwidth info for a certain user may be repeated.

User:A Bandwidth:50 CountryCode:IND

User:B Bandwidth:60 CountryCode:USA

User:A Bandwidth:70 CountryCode:IND

(i) Find total amount of bandwidth consumed per user

(ii) Suppose there are 4 country codes, for every country code, find the top 5 users which consumed maximum bandwidth sorted.| Report Duplicate | Flag | PURGE

Amazon - -1of 1 vote

AnswersGiven a matrix. Convert it into a linked list matrix such that each node is connected to its next right and down node.

Ex:

1 2 3

4 5 6

7 8 9

Output:

1->2->3->NULL

| | |

v v v

4->5->6->NULL

| | |

v v v

7->8->9->NULL

| | |

v v v

--NULL-

This is my code.`class Ideone { public static void main(String args[]) throws Exception { int arr[][] = { { 1, 2, 3 }, { 4, 5, 6 } }; LList op = convert2DArrintoList(arr, 0, 0); System.out.println(op); } public static LList convert2DArrintoList(int arr[][], int col, int row) { if (col >= arr[0].length || row >= arr.length) return null; return new LList(arr[row][col], convert2DArrintoList(arr, col, row + 1), convert2DArrintoList(arr, col + 1, row)); } static class LList { LList(int data) { this.data = data; } LList(int data, LList down, LList next) { this.data = data; this.down = down; this.next = next; } LList() { this.data = Integer.MAX_VALUE; } @Override public String toString() { return " " + this.data + " "; } int data; LList next; LList prev; LList rand; LList down; } }`

Are there better ways of doing it?

- koustav.adorable August 16, 2017 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

Answers// Create a numeric binary tree structure/classes that have left and right children and an integer numeric value.

- deepmh August 14, 2017 in United States for Amazon Fresh

// Write a function 'isBalanced' for a node that returns true if the sum of all the children on the left is equal

// to the sum of all the children on the right.

//Example:

// [12] [12].isBalanced() -> True. [3, 3]

// / \

// [3] [1] [1].isBalanced() -> True. [2, 2]

// / \

// [2] [0]

// / \

// [2] [0]

// - Part I: setup and isBalanced() function

// - Part II: implement “allBalancedNodes()” <— given a node, finds all balanced children

// allBalancedNodes(12) -> returns a list of balanced nodes: { [1], ... }| Report Duplicate | Flag | PURGE

Amazon SDE-3 Data Structures - -1of 1 vote

AnswersGiven a fully connected graph with n nodes and corresponding values. One node can interact with other node at a time, to replace/ignore/add its value to other node’s value. Assuming this operation takes 1 unit of time, how much time would it take for all the nodes to have value equal to sum of all the nodes.

- koustav.adorable August 14, 2017 in United States

Examples : Given a graph with values {1,2,3,4}, find total time it takes, such that all nodes have value as 10.

I am assuming it can be done in O(N).It will take basically two traversals, one for calculating the sum of values of nodes(first traversal), other for replacing the value of the nodes(second traversal).

It will take 2*(no of nodes) time.

Are there any better ways possible ?| Report Duplicate | Flag | PURGE

Amazon SDE-2 Data Structures - 0of 0 votes

AnswersDesign amazon's frequently viewed product page.

- Nascent August 11, 2017 in India| Report Duplicate | Flag | PURGE

Amazon SDE-2 - 0of 0 votes

AnswersDesign a ESPN like system. Ensure scaling and availability. Also one should get all details like score of a player, no. of mtches etc.

- Nascent August 11, 2017 in India| Report Duplicate | Flag | PURGE

Amazon SDE-2 - 2of 2 votes

AnswersDesign a FIDS(Flight Information Display System)

- AD August 04, 2017 in India

1. Consider most important classes & ignore Interfaces as of now

2. FIDS is not about reservation system but the dasboard to display

3. the information will look like:

DEPARTURES

----------------------

Attributes:

STD Airline Flight Destination/Via CheckInCounter# Gate Status ETD

Values :

12:50 KingFisher 6E352 Hyderabad A-B 23 Check-In Open 13:15

ARRIVALS

-----------------------

Attributes:

STA Airline Flight# Destination/Via Gate Status ETA

Values :

12:50 KingFisher 6E352 UK/Mumbai Terminal2 Landed 13:15| Report Duplicate | Flag | PURGE

Amazon SDE-2 System Design

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

Open Chat in New Window