Amazon interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Amazon
upvote
share-icon
3 rounds | 6 Coding problems

Interview preparation journey

expand-icon
Journey
I began my coding journey in my second year of college, diving into the basics while simultaneously getting involved in competitive programming. I regularly participated in coding contests, which helped sharpen my problem-solving skills. Over time, I built a strong foundation in algorithms and data structures, which proved invaluable. This dedication paid off when I secured a summer internship at Arcesium. The experience gained during my internship, along with consistent practice and learning, ultimately helped me succeed in job interviews.
Application story
I participated in an online hackathon hosted by Amazon in April 2021, and a few months later, in August 2021, I received an interview call as a result of my performance.
Why selected/rejected for the role?
I gained valuable experience through a prior internship, which helped me strengthen my technical skills. Additionally, I excelled in competitive programming, achieving strong ratings on coding platforms. My consistent participation in coding challenges not only improved my problem-solving abilities but also built my confidence. Alongside competitive programming, I worked on several meaningful projects that showcased my knowledge of web development and other technologies. Furthermore, I had a great experience in a major hackathon, where I applied my skills in real-world scenarios. All of these experiences collectively helped me succeed.
Preparation
Duration: 12 months
Topics: Data structure, Algorithms, SQL, Operating System, DBMS, Web development
Tip
Tip

Tip 1: Begin by mastering data structures, then actively participate in coding contests. Make it a habit to solve at least one additional problem after each contest.

Tip 2: Challenge yourself by solving problems that are slightly above your current rating to steadily improve your skills.

Tip 3: Build a few projects using the technologies you're passionate about to strengthen your practical knowledge and showcase your abilities.

Application process
Where: Other
Eligibility: N/A, (Salary Package - 47LPA)
Resume Tip
Resume tip

Tip 1: Build a strong portfolio, whether through competitive programming achievements or web development projects.

Tip 2: Thoroughly prepare by anticipating and practising answers to all potential questions related to your resume.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration60 minutes
Interview date11 Aug 2021
Coding problem2

This round was scheduled for around 8 AM. The interviewer was very friendly, and I was asked to share the complete approach and code it down.

1. Time To Burn Tree

Hard
50m average time
50% success
0/120
Asked in companies
OLX GroupPhonePeMicrosoft

You have a binary tree of 'N' unique nodes and a Start node from where the tree will start to burn. Given that the Start node will always exist in the tree, your task is to print the time (in minutes) that it will take to burn the whole tree.


It is given that it takes 1 minute for the fire to travel from the burning node to its adjacent node and burn down the adjacent node.


For Example :
For the given binary tree: [1, 2, 3, -1, -1, 4, 5, -1, -1, -1, -1]
Start Node: 3

    1
   / \
  2   3
     / \
    4   5

Output: 2

Explanation :
In the zeroth minute, Node 3 will start to burn.

After one minute, Nodes (1, 4, 5) that are adjacent to 3 will burn completely.

After two minutes, the only remaining Node 2 will be burnt and there will be no nodes remaining in the binary tree. 

So, the whole tree will burn in 2 minutes.
Problem approach

Create a hashmap to map each node to its parent.

Set up pointers to point to the node with the target value.

Write a recursive function that calculates the distance to all leaf nodes.

Return the maximum distance among them.

Try solving now

2. Ninja’s Safe

Moderate
30m average time
70% success
0/80
Asked in companies
UberAmazonalibaba

After an accident, Ninja is suffering from transient amnesia. He wants to open his safe but has forgotten his password.

The safe’s lock has 4 circular wheels. Each wheel has 10 slots: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The wheels can rotate clockwise as well as anti-clockwise: for example, we can turn 9 to be 0, or 0 to be 9. Each move consists of turning one wheel in one slot.

The lock initially starts at 0000, a string representing the state of the 4 wheels.

Ninja is given a list of ‘blockages’ dead ends, meaning if the lock displays any of these codes, the wheels of the lock will stop turning, and Ninja would be unable to open it.

There would be a ‘result’ given representing the wheels' value that will unlock the lock, return the minimum total number of turns Ninja is required to open the lock, or -1 if it is impossible for him to open it.

Help Ninja to open his safe.

Problem approach

Using BFS, we can explore all possible lock combinations, starting from "0000." At each step, we generate the neighbours of the current lock state by turning each of the four circular wheels either clockwise or counterclockwise. We then move to the next valid neighbour, as long as it isn't part of the dead. If we reach the target lock, the current number of steps will represent the minimum number of turns needed to open the lock.

Try solving now
02
Round
Easy
Online Coding Interview
Duration60 Minutes
Interview date17 Aug 2021
Coding problem2

This round started around 10 AM.

1. Find Median from Data Stream

Moderate
20m average time
76% success
0/80
Asked in company
Amazon

The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value and the median is the mean of the two middle values.

Example:
Median for ‘arr’ = [1,2,3,4,5] is 3.
Median for ‘arr’ = [1,2,3,4] is (2+3)/2 = 2.5.

Implement the MedianFinder class:

MedianFinder() initialises the MedianFinder object.

1. Void addNum(int ‘num’) adds the integer ‘num’ from the datastream to the data structure.

2. Double findMedian() returns the median of all elements so far.

Note : Answers within 10^-5 of actual answer will be accepted.

Example:
Input: 
5
1 1
1 2
2
1 5
2

Output:     
1.5
2

Explanation:
MedianFinder() initialises the MedianFinder object.
Add 1 to the data structure ‘arr’, so arr = [1].
Add 2 to arr, so arr = [1,2]
Find Median of current arr, that is (1+2)/2 = 1.5.
Add 5 to arr, so arr = [1,2,5]
Find Median of current arr, that is 2.0.
Problem approach

I maintain two heaps (or priority queues):

- The max-heap small stores the smaller half of the numbers.

- The min-heap large stores the larger half of the numbers.

This setup gives me direct access to the one or two middle values (which are at the tops of the heaps), allowing me to get the median in O(1) time. Adding a number takes O(log n) time.

Supporting both min- and max-heaps can be somewhat cumbersome depending on the programming language, so I simply negate the numbers in the heap where I need the reverse of the default order.

Try solving now

2. My Calendar III

Easy
10m average time
90% success
0/40
Asked in companies
FacebookAmazon

A k-booking happens when k events have some non-empty intersection (i.e., there is some time that is common to all k events.) You are given some events [start, end), after each given event, return an integer k representing the maximum k-booking between all the previous events.

Implement the MyCalendarEvents class:

MyCalendarEvents() Initializes the object.

int book(int start, int end) Returns an integer k representing the largest integer such that there exists a k-booking in the calendar.

Note:
Here the start of the event is included while the end is not as part of the slot i.e. the slot end right before the end.
For Example
Input:
["MyCalendarEvents", "book", "book", "book", "book", "book", "book"]
[[], [10, 20], [50, 60], [10, 40], [5, 15], [5, 10], [25, 55]]  
Output:
[null, 1, 1, 2, 3, 3, 3]

Explanation:
MyCalendarEvents myCalendarEvent = new MyCalendarEvents();
myCalendarEvent.book(10, 20); // return 1, The first event can be booked and is disjoint, so the maximum k-booking is a 1-booking.
myCalendarEvent.book(50, 60); // return 1, The second event can be booked and is disjoint, so the maximum k-booking is a 1-booking.
myCalendarEvent.book(10, 40); // return 2, The third event [10, 40) intersects the first event, and the maximum k-booking is a 2-booking.
myCalendarEvent.book(5, 15); // return 3, The remaining events cause the maximum K-booking to be only a 3-booking.
myCalendarEvent.book(5, 10); // return 3
myCalendarEvent.book(25, 55); // return 3
Problem approach

We use a map count where time points serve as the keys. If count[t] exists, it represents the number of events happening at time t, continuing until the next time point.

Now, let’s break down the map operation: count.emplace(t, (--count.lower_bound(t))->second).

If the map already contains the key t, no insertion occurs and the map remains unchanged. count.emplace(t, value) returns a pair of in this case.

If the key t is absent, count.emplace(t, value) inserts the value and returns.

count.upper_bound(s) retrieves the first iterator after t, while --count.upper_bound(s) gets the first iterator before t, allowing us to access the event count at t. This value is then inserted into count[t].

Next, we iterate over all time points within the specified time window and increment them accordingly.

Try solving now
03
Round
Medium
Online Coding Interview
Duration60 minutes
Interview date21 Aug 2021
Coding problem2

1. Find Maximum value of array

Given an array A of size n, the safe value is defined by |A[I]-A[j]|+|I-j|, find the maximum safe value in the array. (Learn)

Problem approach

The absolute value expressions can be expanded into different cases based on the signs of A[i] - A[j] and i - j. This gives us four cases:
A[i] - A[j] + i - j
A[i] - A[j] - (i - j)
-(A[i] - A[j]) + i - j
-(A[i] - A[j]) - (i - j)

These simplify to:
(A[i] + i) - (A[j] + j)
(A[i] - i) - (A[j] - j)
-(A[i] - i) + (A[j] - j)
-(A[i] + i) + (A[j] + j)

For each case, we need to maximize the difference between two expressions. Specifically:
Case 1: Maximize A[i] + i and subtract the minimum of A[j] + j.
Case 2: Maximize A[i] - i and subtract the minimum of A[j] - j.

We can iterate through the array once to compute the following values:
Maximum and minimum of A[i] + i.
Maximum and minimum of A[i] - i.

2. Meetings II

Moderate
10m average time
90% success
0/80
Asked in companies
IBMUrban Company (UrbanClap)BNY Mellon

Stark Industry is planning to organize Stark Expo, for which various departments have to organize meetings to check their preparations. Since Stark Tower has limited rooms available for the meeting, Tony decided to allot a room to each meeting so that all the meetings are organized in the least possible conference rooms, and a the moment, only one meeting will happen in one room. So, he asked JARVIS to allot each meeting a room and tell the minimum number of conference rooms to be reserved. But, since JARVIS was busy rendering another Iron Man suit model, he asked you to help.

You are given an array of integers ARR of size N x 2, representing the start and end time for N meetings. Your task is to find the minimum number of rooms required to organize all the meetings.

Note:

1. You can assume that all the meetings will happen on the same day.
2. Also, as soon as a meeting gets over if some other meeting is scheduled to start at that moment, they can then be allocated that room.

Note:

Try to solve the problem in linear time complexity.

For Example:

Consider there are three meetings scheduled with timings:
1pm - 4pm
3pm - 5pm
4pm - 6pm

At the start of time, meeting 1 will be allotted room 1, which will be occupied till 4 pm hence for meeting 2 we’ll have to provide another room. At 4 pm, meeting 3 can be organized in room 1 because by that time, meeting 1 would have ended. Hence we’ll require two rooms for holding all three meetings.
Problem approach

To solve the problem of determining which room hosted the most meetings, you can follow this approach:

Initialization:
Use a priority queue to manage available rooms and track when each room will be free.
Use another priority queue to manage ongoing meetings, storing their end times and associated rooms.
Maintain a list to count the number of meetings hosted by each room.

Sort Meetings:
Sort the meetings based on their start times to process them in chronological order.

Process Meetings:
For each meeting, check if there are any rooms available. If there are, assign the meeting to the room with the smallest number.
If no rooms are available, determine which room will be free at the soonest. Update this room's availability and start time.
Update the end time of the meeting in the priority queue and count the meeting for the assigned room.

Handle Room Availability:
Whenever a meeting ends, the room becomes available again. Update the room's status and reinsert it into the priority queue of available rooms.
Ensure that rooms are reassigned based on the earliest meeting start times.

Determine the Most Frequent Room:
After all meetings have been processed, scan through the count list to find the room that hosted the most meetings. If there is a tie, choose the room with the smallest number.

Try solving now

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
3 rounds | 5 problems
Interviewed by Amazon
3085 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Amazon
2295 views
1 comments
0 upvotes
company logo
SDE - 1
3 rounds | 6 problems
Interviewed by Amazon
1593 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Amazon
8962 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
58238 views
5 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Samsung
12649 views
2 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Microsoft
5983 views
5 comments
0 upvotes