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

SDE - 2

Amazon
upvote
share-icon
6 rounds | 8 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: DS/Algo, System Design, HLD, LLD, Behavioral questions
Tip
Tip

Tip 1 : 250 Leetcode ( Easy- 70, Medium- 150, Hard- 30) 
Tip 2 : Don't underestimate importance of good projects on your Resume.
Tip 3 : Be Confident.

Application process
Where: Linkedin
Eligibility: 3+ years Experience
Resume Tip
Resume tip

Tip 1: Resume should not be more than 1 page.
Tip 2: Have Keywords on Resume that match Job descriptions.

Interview rounds

01
Round
Medium
Face to Face
Duration60 mins
Interview date24 Aug 2019
Coding problem3

3 Questions were asked : 2- Trees and 1- Stack.
Interviewer was not receptive at all, I think this was a stress interview.

1. Validate Binary Search Tree

Moderate
25m average time
70% success
0/80
Asked in companies
FacebookAmazonMicrosoft

Given a binary tree with N number of nodes, check if that input tree is Partial BST (Binary Search Tree) or not. If yes, return true, return false otherwise.

A binary search tree (BST) is said to be a Partial BST if it follows the following properties.

• The left subtree of a node contains only nodes with data less than and equal to the node’s data.
• The right subtree of a node contains only nodes with data greater than and equal to the node’s data.
• Both the left and right subtrees must also be partial binary search trees.
Example:

Input:

BST1

Answer:

Level 1: 

All the nodes in the left subtree of 4 (2, 1, 3) are smaller 
than 4, all the nodes in the right subtree of the 4 (5) are 
larger than 4.

Level 2 :

For node 2:
All the nodes in the left subtree of 2 (1) are smaller than 
2, all the nodes in the right subtree of the 2 (3) are larger than 2.
For node 5:
The left and right subtree for node 5 is empty.

Level 3:

For node 1:
The left and right subtree for node 1 are empty.
For node 3:
The left and right subtree for node 3 are empty.
Because all the nodes follow the property of a Partial binary 
search tree, the above tree is a Partial binary search tree.
Problem approach

Inorder Traversal and Check if previous element is smaller than next one

Try solving now

2. Binary Tree - Replace every node with Sum of nodes Greater than that node

Moderate
25m average time
65% success
0/80
Asked in companies
AmazonSamsungOracle

Given a binary tree with 'N' number of nodes, convert it to a Greater Tree such that data of every node of the original BST is changed to the original node’s data plus the sum of all node’s data greater than or equal to the original data of the node in the BST.

A binary search tree (BST) is a binary tree data structure that has the following properties.

• The left subtree of a node contains only nodes with data less than the node’s data.

• The right subtree of a node contains only nodes with data greater than the node’s data.

• Both the left and right subtrees must also be binary search trees.
Example:

Example

Answer:

Because only 5 is greater than 4 in the above BST, node 4 will be updated to 9 (4 + 5 = 9).

Nodes 3, 4, and 5 are greater than 2, hence node 2 will be modified to 14 (2 + 3 + 4 + 5 = 14). 

Node with data 5 will remain the same because there is no node in the BST with data greater than 5.

Nodes 2,3, 4, and 5 are greater than 1, hence node 1 will be modified to 15 (1 + 2 + 3 + 4 + 5 = 15).   

Nodes 4 and 5 are greater than 3, hence node 3 will be modified to 12 (3 + 4 + 5 = 12). 
Problem approach

I took Reverse Inorder in this approach and started from last element in right subtree
Traversed the Tree in Reverse Inorder Fashion Right Root Left.

Try solving now

3. Check if String has Valid parenthesis ()[]{}

Easy
10m average time
80% success
0/40
Asked in companies
OracleSwiggyAmerican Express

You're given a string 'S' consisting of "{", "}", "(", ")", "[" and "]" .


Return true if the given string 'S' is balanced, else return false.


For example:
'S' = "{}()".

There is always an opening brace before a closing brace i.e. '{' before '}', '(' before ').
So the 'S' is Balanced.
Problem approach

I used Stack data structure for this problem and Solved in O (n) Space Complexity
Interviewer asked to optimise this to O(1) Space which i was not able to optimise.

Try solving now
02
Round
Hard
Face to Face
Duration60 mins
Interview date24 Aug 2019
Coding problem2

2 Coding Questions were asked, both were of Medium to Hard Difficulty.

1. Rearrange linked list with child and next pointers into a single linked list.

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

You are given a multi-level linked list of 'N' nodes, each node has a next and child pointer which may or may not point to a separate node. Flatten the multi-level linked list into a singly linked list. You need to return the head of the updated linked list.

Example:

Sample Multi-Level

Flatten :

All the different rows are merged into a single row.
Problem approach

I used BFS approach here, and made use of Queue Data structure
I kept on storing Child elements of a node in Queue.

Try solving now

2. Rain Water Trapping Problem

Moderate
15m average time
80% success
0/80
Asked in companies
SalesforcePayPalHexaware Technologies

You have been given a long type array/list 'arr’ of size 'n’.


It represents an elevation map wherein 'arr[i]’ denotes the elevation of the 'ith' bar.



Note :
The width of each bar is the same and is equal to 1.
Example:
Input: ‘n’ = 6, ‘arr’ = [3, 0, 0, 2, 0, 4].

Output: 10

Explanation: Refer to the image for better comprehension:

Alt Text

Note :
You don't need to print anything. It has already been taken care of. Just implement the given function.
Problem approach

I used two Arrays here Min and Max to store all elements min/max for a Particular element

Try solving now
03
Round
Medium
Face to Face
Duration90 minutes
Interview date24 Aug 2019
Coding problem1

Timing : It was late night.
How the interviewer was? He was very tired and I had to lead the discussion.
1 System Design Question was asked, had to provide - HLD, LLD, APIs.

1. Design Swiggy/Zomato - Online Food ordering System

Problem approach

Tip 1: Ask clarifying questions and make sure you boil down to Minimum Viable product
Tip 2: Restrict Scope of problem to essential Features for eg: Customer support, Discounts/Offers can be pushed to Future Requirements.
Tip 3: Keep talking to interviewer and ask if you are going in right direction, there is not a single solution for design, so make sure you justify your designs like - I will use NoSQL, but why ? Justify that, I will use some XYZ tech, why is this best ?
Tip 4: System Design round can go till 4 hours but you just always plan to complete in 60-90 minutes. keep a time check for every 10 minutes and see on which section you are.

04
Round
Medium
Telephonic
Duration60 minutes
Interview date11 Sep 2019
Coding problem1

Timing : Afternoon
How was the environment? Home
Interviewer : Hiring Manager

1. Hiring Manager Discussion

Discussed about past Projects, challenges faced, disagreements with manager, why looking for job switch,  leadership principle questions were asked.

Problem approach

I answered all questions very confidently and was prepared for all Leadership questions. Each answer should be fitting one or two leadership principle.

05
Round
Medium
Telephonic
Duration60 minutes
Interview date26 Sep 2019
Coding problem1

Timing - Afternoon
How was the environment? Home
How the interviewer was? Very Helpful Interviewer
Bar raiser Round - Coding + System Design + Leadership principle

1. Design ATM System

Problem approach

Tip 1: Ask clarifying questions and make sure you boil down to Minimum Viable product
Tip 2: Write down all Entities and Interface and make use of OOPs Concepts like abstraction, Encapsulation, etc
Tip 3: Design patterns is a good to have, you can showcase this skill for SDE 2.

06
Round
Easy
HR Round
Duration30 minutes
Interview date15 Oct 2020
Coding problem0

Discussed about the Offer and Location.

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 create a function in JavaScript?

Choose another skill to practice
Start a Discussion
Similar interview experiences
company logo
SDE - 2
3 rounds | 4 problems
Interviewed by Amazon
1563 views
0 comments
0 upvotes
company logo
SDE - 2
5 rounds | 7 problems
Interviewed by Amazon
1020 views
0 comments
0 upvotes
company logo
SDE - 2
4 rounds | 8 problems
Interviewed by Amazon
2029 views
0 comments
0 upvotes
company logo
SDE - 2
5 rounds | 7 problems
Interviewed by Amazon
508 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 2
5 rounds | 12 problems
Interviewed by Walmart
24080 views
8 comments
0 upvotes
company logo
SDE - 2
4 rounds | 7 problems
Interviewed by Dunzo
2466 views
0 comments
0 upvotes
company logo
SDE - 2
3 rounds | 4 problems
Interviewed by Samsung
2057 views
0 comments
0 upvotes