## Amazon Interview Questions

- 0of 0 votes
how does java implement priority queue?

i answered min heap, the interviewer seemed it was not right

- 0of 0 votes
Amazon SDE 2 On-site (1 of 4 Rounds)

In a file system stored a large amount of user’s browsing data, including the urls that the user visited. Design a function that outputs the longest common path of all the urls.

Having finished the code, I was asked to analyze the complexity.

- 0of 0 votes
Amazon SDE 2 On-site (4 of 4 Rounds)

Assume that there is an e-book application. For every book the sharable part of the book content cannot exceed 10% of the whole book. Design a module to decide whether the current part of content is sharable.

The description given is vague. I had to push him with questions to give the details.

At first I thought the problem was about strStr. But then the interviewer said that even if there are two paragraphs of the book content with the exact same texts, as long as they are not in the same place, they would be considered different content.

I then realized it’s a question about merging segments - have a helper to find each pair of start and end point of the input content (given multiple separated paragraphs). Then merge the intervals and see if they combined exceed 10% of the entire book.

The interviewer approved my solution and ask me to code it.

Overall I feel like that the Amazon SDE II Interview doesn’t focus on just algorithm. It’s more about problem solving in practice and then implement the only core function on whiteboard.

- 0of 0 votes
Perform an efficient DeepCopy of a linked list whose node is like below:

`public class Node { public int Value {get;set;} public Node Next{get;set;} public Node Random{get;set;} }`

The Random field points to any random node in the list.

- 0of 0 votes
Write code for the following: given a text file containing this information (Date the customer is logged in, tab, customer id)

04/11/2017 /t 0003

04/12/2017 /t 0003

04/13/2017 /t 0004

04/13/2017 /t 0003

How to get the list of those customers that log in on three consecutive days.

- 0of 0 votes
OOPS: How to design Amazon locker? Provide code using OOP

- 0of 0 votes
How to merge two binary trees in place? (without creating a new node)

- 0of 0 votes
You are given a rotated sorted array of size N. You have to search a given number into it.

Example: [4,6,8,14,90,-9,-2,0,3], Search -2.

- 0of 0 votes
Write a program which takes input a sorted array and positive number and updates the array so that if x appears m times in array then it appears exactly min(2,m) times in array. the update should be performed in one pass with no additional memory

- 0of 0 votes
What design pattern is used to implement a SynchronizedHashMap?

- 0of 0 votes
You are given an unsorted binary array.

Ex [0 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 1]

and a number K, which represents the number of swap operations allowed on this binary array.

you need to find out the maximum length continuous subarray that can be generated using K many swaps.

Ex if K = 3 in above case

[0 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 1] => [0 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1] => [0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0] => [0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0]

so the answer is 9.

- 0of 0 votes
You are given a binary matrix whose each row is sorted. that means each row will have zeros at front and ones at the back. You need to find out the row which contains a maximum number of ones.

Ex :`[0 0 0 0 0 0 0 1 1 1 1 1] [0 0 0 0 1 1 1 1 1 1 1 1] [0 0 0 0 0 0 1 1 1 1 1 1] [0 0 0 0 0 0 0 0 0 1 1 1] [0 0 0 0 0 0 0 1 1 1 1 1] [0 0 0 0 1 1 1 1 1 1 1 1]`

Ans : second row and sixth with 8 ones. you will print [2,8] and [6,8];

Update : Required complexity O(M+N) + O(1) only.

- 0of 0 votes
Design a system to monitor services (like when they were down/ CPU time) etc.

- 0of 0 votes
Design a system for dashboard that effectively shows almost real time data.

- 0of 0 votes
Implement a stack that in addition to push and pop has a function that returns the min value of the stack.

I came up with a O(logn) solution, but he wanted a O(1) for the whole algorithm.

- 2of 2 votes
Given a sorted array with "n" elements, distributed them into "k" nearly equally weighing buckets.

Space is not constraint.

Ex: [1,3,6,9,10]

bucket size: 3

output:[10],[9,1],[3,6]

- 1of 1 vote
Add two link list, can not modify the link list, can not reverse the link list first and second.

Link list 1 - 1->2->3->7

Link list 2 - 2->9

Out put Sum - 1->2->6->6

- -1of 3 votes
Find the frequency of a number in array in less than bigo n time

Array 1,2,2,3,4,5,5,5,2

Input 5

Output 3

Array 1,1,1,1,

Input 1

Output 4

Keep in mind less than bigo n

Thanks

- 2of 2 votes
Design backend system for bookMyShow.com like system which supports below use cases:

1) When user selects cities, list of cities is displayed.

2) When user selects city, movie list is displayed.

3) When user selects movie, list of theatre is displayed.

4) When user selects theatre, show timing is displayed.

5) When show timing is selected, user is asked for no of seats that he wants to book

6) When user selects no of seats, seats are displayed to choose from.

7) When user selects seats, then total price is displayed.

8) When total price is selected, then user is directed to payment gateway and payment is done and on payment success, ticket is mailed to him.

More questions on how can we scale the system, and handle concurrent users request for same seat etc.

- 0of 0 votes
Design a movie ticket booking system like bookmyshow.com

Follow-up question -

1) How do you handle issues like scalability, concurrency, fault-tolerance etc.

2) Show movie theaters near to user where movie is playing and seats are available

3) Design database. What kind of DB would you use SQL or No-SQL

4) In real time how would you show which seats are booked which are free

5) If theaters do not have any api for fetching information then what can we do about it.

- 1of 1 vote
Design Uber. Low level Design needed (OOPS based - classes, relations, message flow etc.)

- 0of 0 votes
Design Cricinfo website

- 0of 0 votes
Design snake n ladder game to be played online

- 0of 0 votes
This is a system design question. Design a Event booking system. Imagine that event registry etc is all implemented. A user can log in, check the available events and then books it. Design a system for event booking

- -1of 1 vote
Find K which decides the number of open brackets are equal to the number of closed brackets.

input : (())

output : 2

Reason : if we divide the string at 2nd position, we get two open brackets and two closing brackets, and they are same .

input : (())))(

output : 4

Reason : if we divide the string(not necessarily equally) at 4rth position, we have (()) on the left side and on the right side we have ))( , as you can see, on the left half, we have two opening brackets and on the right half we have two closing brackets and they are equal .

input : ))

output : 2

Reason : there is no open brackets , so if we divide taking the whole string's length, we have )) on the left half and nothing on the right half. Now you can see that on the left half there is no open brackets and on the right half there is no closed brackets.

This question should be clear by now and remember you have to find out that K .

- -4of 4 votes
Fill the arrray with elements from 0 to 9.

based on thier frequency.

a[1]=3 means, 1 is repeated for 3 times(1 must present 3 times in that array)

a[2]=4 means 2 is repeated for 4 times.(2 must present twice in that array)

- 0of 0 votes
Find the Maximum number of distinct nodes in a binary tree path

- 0of 0 votes
Write test cases to test a browser App

- 1of 1 vote
A = "ffgggtvshjsdhjfffffffhvjbjcharu"

Find the max consecutive repitative chracter

Output : f -> 7

- 0of 0 votes
A = {1,2,4,-6,5,7,9,....}

B = {3, 6, 3, 4, 0 .......}

n = 5 -> pairs whose sum is n

Output = (1,4), (5,0)....