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
Preparation
Duration: 12 months
Topics: C++, Data Structure, Dynamic Programming, Operating system, System Design
Tip
Tip

Tip 1 : Practice coding questions and participate in online contests.
Tip 2 : Communication skills are good to have for interviews.
 

Application process
Where: Campus
Eligibility: 7 CGPA
Resume Tip
Resume tip

Tip 1 : Do some good projects for your resume.
Tip 2 : Keep it concise and short.
Tip 3 : Don't lie on your resume.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration150 minutes
Interview date15 Dec 2020
Coding problem2

Amazon Visited our campus, and they had put a cutoff of 7 CGPA based on which they shortlisted students. After 2 days all the shortlisted students received an online test link.

Online Assessment Test: The round had four sections.

Debugging: There was a total of 7 questions in which a piece of code was written and you had to find any error so that all the test cases can pass. All the questions were very easy.
Coding Section: There were two questions, one was based on a linked list and the other was a logical question based on hashing, I would say both the questions were of medium level. The time allotted was 70 mins total.
Behavioral Analysis: This section consisted of questions that focused on your personality and behavior.
Reasoning Ability: This section was based on aptitude and verbal ability. The difficulty level was easy.

1. Add two number as linked lists

Moderate
10m average time
80% success
0/80
Asked in companies
QuikrMicrosoftAdobe

You have been given two singly Linked Lists, where each of them represents a positive number without any leading zeros.

Your task is to add these two numbers and print the summation in the form of a linked list.

Example:
If the first linked list is 1 -> 2 -> 3 -> 4 -> 5 -> NULL and the second linked list is 4 -> 5 -> NULL.

The two numbers represented by these two lists are 12345 and 45, respectively. So, adding these two numbers gives 12390. 

So, the linked list representation of this number is 1 -> 2 -> 3 -> 9 -> 0 -> NULL.
Problem approach

The approach is very simple. Traverse both lists and One by one pick nodes of both lists and add the values. If the sum is more than 10 then make carry as 1 and reduce sum. If one list has more elements than the other then consider the remaining values of this list as 0.

The steps are:
1. Traverse the two linked lists from start to end
2. Add the two digits each from respective linked lists.
3. If one of the lists has reached the end then take 0 as its digit.
4. Continue it until both the end of the list.
5. If the sum of two digits is greater than 9 then set carry as 1 and the current digit as sum % 10

Try solving now

2. Two Sum

Easy
10m average time
90% success
0/40
Asked in companies
MeeshoAdobeInfo Edge India (Naukri.com)

You are given an array of integers 'ARR' of length 'N' and an integer Target. Your task is to return all pairs of elements such that they add up to Target.

Note:

We cannot use the element at a given index twice.

Follow Up:

Try to do this problem in O(N) time complexity. 
Problem approach

This problem can be solved efficiently by using the technique of hashing. Use a hash_map to check for the current array value x(let), if there exists a value target_sum-x which on adding to the former gives target_sum. This can be done in constant time. Let’s look at the following example.

arr[] = {0, -1, 2, -3, 1}
sum = -2
Now start traversing:
Step 1: For ‘0’ there is no valid number ‘-2’ so store ‘0’ in hash_map.
Step 2: For ‘-1’ there is no valid number ‘-1’ so store ‘-1’ in hash_map.
Step 3: For ‘2’ there is no valid number ‘-4’ so store ‘2’ in hash_map.
Step 4: For ‘-3’ there is no valid number ‘1’ so store ‘-3’ in hash_map.
Step 5: For ‘1’ there is a valid number ‘-3’ so the answer is 1, -3

Try solving now
02
Round
Medium
Video Call
Duration90 minutes
Interview date16 Dec 2020
Coding problem2

The round began and first, the interviewer introduced himself and later asked me to introduce myself which I did. After that, he walked me through how the interview is going to proceed from there. He then gave me two coding questions, firstly you have to tell them your approach, and if they are satisfied enough or if your approach is the optimum approach then they will ask you to write that code in their code space which is not an editor btw.

After half an hour I got a call from HR that my interview is scheduled an hour later.

1. Square root (decimal)

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

You have been given two integers 'N' and 'D', Your task is to find the square root of the number 'N' with precision up to 'D' decimal places i.e. the difference between your answer and the correct answer should be less than 10 ^ (-D).

For example if N = 10 and D = 3, then your answer will be 3.162.

Problem approach

So, this was a binary search question and there was an easier version of this question in which you had to find only the integer which is closest to the square root of that number, so here you had to only change your code a bit, but the logic was a bit tricky to find, but eventually, I came up with the solution and then the interviewer was quite impressed. I also had to tell the time and space complexity and also explained to them why was this the most optimal approach.

Try solving now

2. Spiral Order Traversal of a Binary Tree

Easy
20m average time
75% success
0/40
Asked in companies
PayUAtlassianAmazon

You have been given a binary tree of 'N' nodes. Print the Spiral Order traversal of this binary tree.

For example
For the given binary tree [1, 2, 3, -1, -1, 4, 5, -1, -1, -1, -1]
    1
   / \
  2   3
     / \
    4   5

Output: 1 3 2 4 5
Problem approach

Initially, I thought that this was a tricky problem but I kept thinking out loud, and they were also able to see where and how was I thinking, later I came up with the solution and it was the optimum one, the interviewer again asked me to write how will you represent the generic tree, and then I wrote the code for the tree using a class, the interviewer was again happy to see that, later I wrote the code for the problem and also told him the time and space complexities.

Approach: The idea is to use two variables i initialized to 1 and j initialized to the height of the tree and run a while loop which won't break until i becomes greater than j. We will use another variable flag and initialize it to 0. Now in the while loop, we will check a condition that if the flag is equal to 0 we will traverse the tree from right to left and mark the flag as 1 so that next time we traverse the tree from left to right and then increment the value of i so that next time we visit the level just below the current level. Also when we will traverse the level from the bottom we will mark the flag as 0 so that next time we traverse the tree from left to right and then decrement the value of j so that next time we visit the level just above the current level. Repeat the whole process until the binary tree is completely traversed.

Try solving now
03
Round
Easy
HR Round
Duration90 minutes
Interview date16 Dec 2020
Coding problem2

The round began with the interviewer’s introduction and then I introduced myself He gave me two questions based on data structures.

The interviewer was happy with all the answers. Then, since enough time was left, He asked me some HR questions, like what are strengths and weaknesses, etc. 

After all this, he told me in the interview itself “See you soon and enjoy your day “, after which I was quite sure that I’m going to go to the next round. But this was the last one.

1. Connect n ropes with minimum cost

Easy
20m average time
80% success
0/40
Asked in companies
ArcesiumUberOptum

You have been given 'N' ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. We need to connect the ropes with minimum cost.

The test-data is such that the result will fit into a 32-bit integer.

Problem approach

Tip 1 : Try to tell your approach continuously, as if you are stuck then the interviewer might give a hint.
Tip 2 : Be confident and speak what you think.
Tip 3 : Don't give up on the first try, try to come up with some solution. They see your approach.

Try solving now

2. Bottom view of binary tree

Moderate
10m average time
90% success
0/80
Asked in companies
OYOMicrosoftAmazon

You are given a 'Binary Tree'.


Return the bottom view of the binary tree.


Note :
1. A node will be in the bottom-view if it is the bottom-most node at its horizontal distance from the root. 

2. The horizontal distance of the root from itself is 0. The horizontal distance of the right child of the root node is 1 and the horizontal distance of the left child of the root node is -1. 

3. The horizontal distance of node 'n' from root = horizontal distance of its parent from root + 1, if node 'n' is the right child of its parent.

4. The horizontal distance of node 'n' from root = horizontal distance of its parent from the root - 1, if node 'n' is the left child of its parent.

5. If more than one node is at the same horizontal distance and is the bottom-most node for that horizontal distance, including the one which is more towards the right.


Example:
Input: Consider the given Binary Tree:

alt text

Output: 4 2 6 3 7

Explanation:
Below is the bottom view of the binary tree.

alt text

1 is the root node, so its horizontal distance = 0.
Since 2 lies to the left of 0, its horizontal distance = 0-1= -1
3 lies to the right of 0, its horizontal distance = 0+1 = 1
Similarly, horizontal distance of 4 = Horizontal distance of 2 - 1= -1-1=-2
Horizontal distance of 5 = Horizontal distance of 2 + 1=  -1+1 = 0
Horizontal distance of 6 = 1-1 =0
Horizontal distance of 7 = 1+1 = 2

The bottom-most node at a horizontal distance of -2 is 4.
The bottom-most node at a horizontal distance of -1 is 2.
The bottom-most node at a horizontal distance of 0 is 5 and 6. However, 6 is more towards the right, so 6 is included.
The bottom-most node at a horizontal distance of 1 is 3.
The bottom-most node at a horizontal distance of 2 is 7.

Hence, the bottom view would be 4 2 6 3 7


Problem approach

Tip 1 : Try to tell your approach continuously, as if you are stuck then the interviewer might give a hint.
Tip 2 : Be confident and speak what you think.
Tip 3 : Don't give up on the first try, try to come up with some solution. They see your approach.

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