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: 3 months
Topics: Dynamic programming, Binary trees, graphs, strings, Arrays, heaps, HashMap, Sliding Window, Two-pointer, All standard searching and sorting algorithms with their time complexity.
Tip
Tip

Tip 1 : Keep it simple
Tip 2 : Limit your resources
Tip 3 : Practise through different websites.

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

Tip 1 : Link to your projects.
Tip 2 : Open source contribution.
Tip 3 : Clear Tech-stack.
Tip 4 : Link to your different profiles.
Tip 5 : Don't mess up things by writing things you don't know.
Tip 6 : Different Resumes for different job profiles.
Tip 7 : Keep it simple.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration90 minutes
Interview date14 Oct 2020
Coding problem2

No fixed timing(timeslot of around 12 hr)
Environment was stable and time was somewhat less so focus on attending known questions first.
Around 250-300 students were shortlisted

1. Infix To Postfix

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

You are given a string 'exp' which is a valid infix expression.


Convert the given infix expression to postfix expression.


Note:
Infix notation is a method of writing mathematical expressions in which operators are placed between operands. 

For example, "3 + 4" represents the addition of 3 and 4.

Postfix notation is a method of writing mathematical expressions in which operators are placed after the operands. 

For example, "3 4 +" represents the addition of 3 and 4.

Expression contains digits, lower case English letters, ‘(’, ‘)’, ‘+’, ‘-’, ‘*’, ‘/’, ‘^’. 


Example:
Input: exp = ‘3+4*8’

Output: 348*+

Explanation:
Here multiplication is performed first and then the addition operation. Hence postfix expression is  3 4 8 * +.


Problem approach

Read the Prefix expression in reverse order (from right to left)
If the symbol is an operand, then push it onto the Stack
If the symbol is an operator, then pop two operands from the Stack 
Create a string by concatenating the two operands and the operator after them. 
string = operand1 + operand2 + operator 
And push the resultant string back to Stack
Repeat the above steps until end of Prefix expression.

Try solving now

2. Minimum Spanning Tree

Moderate
34m average time
0/80
Asked in companies
MicrosoftAmazonWells Fargo

You are given an undirected, connected and weighted graph G(V, E), consisting of V number of vertices (numbered from 0 to V-1) and E number of edges.

Find and print the total weight of the Minimum Spanning Tree (MST) using Kruskal's algorithm.

By definition, a minimum weight spanning tree is a subset of the edges of a connected, edge-weighted undirected graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight.

Problem approach

Read Dijkstra, Prim's and bellman ford algorithm

Try solving now
02
Round
Medium
Face to Face
Duration45 minutes
Interview date20 Oct 2020
Coding problem2

Timing - 11:00 - 11:45
Interviewer was very helpful

1. LCA - Lowest Common Ancestor

Hard
40m average time
70% success
0/120
Asked in companies
AmazonDell TechnologiesDeutsche Bank

The lowest common ancestor (LCA) is a concept in graph theory and computer science.

Let ‘T’ be a rooted tree with ‘N’ nodes. The lowest common ancestor is defined between two nodes, ‘u’ and ‘v’, as the lowest node in ‘T’ that has both ‘u’ and ‘v’ as descendants (where we allow a node to be a descendant of itself). - Wikipedia

For the given tree, The LCA of nodes 5 and 8 will be node 2, as node 2 is the first node that lies in the path from node 5 to root node 1 and from node 8 to root node 1.

Path from node 5 to root node looks like 5 → 2 → 1.

Path from node 8 to root node looks like 8 → 6 → 2 → 1.

Since 2 is the first node that lies in both paths. Hence LCA will be 2.

Given any two nodes ‘u’ and ‘v’, find the LCA for the two nodes in the given Tree ‘T’.

Note: For each test case, the tree is rooted at node 1.

Problem approach

Following is a simple O(n) algorithm to find LCA of n1 and n2. 
1) Find a path from the root to n1 and store it in a vector or array. 
2) Find a path from the root to n2 and store it in another vector or array. 
3) Traverse both paths till the values in arrays are the same. Return the common element just before the mismatch.

Try solving now

2. Online Stock Span

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

Ninja Coin is a famous crypto-currency in Ninja Land. Ninja has an array/list ‘PRICE’ of size ’N’ where ‘PRICE[i]’ is the price of a Ninja Coin on an ith day in INR, where 0 <= 'i' <= N-1.

The span of the Ninja Coin price on an ith day is defined as the maximum number of consecutive days (starting from the ith day and going backward) for which the price of a Ninja Coin was less than or equal to its price at ith day.

Your task is to return an array/list of size ‘N’ where the ith integer is the span of Ninja Coin price on an ith day. Go through the example for more clarity.

For Example :
Let the price of Ninja Coin for 5 consecutive days is [4, 2, 3, 3, 7].

Then the span of Ninja Coin on the 0th day is 1 because we cannot move backward from day 0.

The span of Ninja Coin on the 1st day is 1 because the price on day 0 is 4 which is greater than 2, so the only day 1 is counted.

The span of Ninja Coin on the 2nd day is 2 because the price on day 2 and day 1 is less than or equal to 3 and then on day 0 price is 4 which is greater than 3, so we count day 2 and day 1.

The span of Ninja Coin on the 3rd day is 3 because the price on day 3, day 2, and day 1 is less than or equal to 3, and on day 0 price is 4 which is greater than 3, so we count day 3, day 2, and day 1.

The span of Ninja Coin on the 4th day is 5 because its value is higher than all previous days values.    

Thus you should return an array/list [1, 1, 2, 3, 5].
Problem approach

In this approach, I have used the data structure stack to implement this task.
Here, two stacks are used. One stack stores the actual stock prices whereas, the other stack is a temporary stack.
The stock span problem is solved using only the Push and Pop functions of Stack.
Just to take input values, I have taken array ‘price’ and to store output, used array ‘span’.

Try solving now
03
Round
Easy
Face to Face
Duration45 minutes
Interview date29 Oct 2020
Coding problem2

Timing: 10:00-10:45

1. Convert A Given Binary Tree To Doubly Linked List

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

Given a Binary Tree, convert this binary tree to a Doubly Linked List.

A Binary Tree (BT) is a data structure in which each node has at most two children.

A Doubly Linked List contains a previous pointer, along with the next pointer and data.

The order of nodes in Doubly Linked List must be the same as Inorder of the given Binary Tree.

The doubly linked list should be returned by taking the next pointer as right and the previous pointer as left.

You need to return the head of the Doubly Linked List.

For the given binary tree :

alt txt

You need to return the head to the doubly linked list.
The doubly linked list would be: 1 2 3 4 5 and can be represented as:

alt txt

Problem approach

In the following implementation, we traverse the tree in inorder fashion. We add nodes at the beginning of current linked list and update head of the list using pointer to head pointer. Since we insert at the beginning, we need to process leaves in reverse order. For reverse order, we first traverse the right subtree before the left subtree. i.e. do a reverse inorder traversal. It took around 40 mins for me to reach optimum solution.

Try solving now

2. LRU Cache Implementation

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

Design and implement a data structure for Least Recently Used (LRU) cache to support the following operations:

1. get(key) - Return the value of the key if the key exists in the cache, otherwise return -1.

2. put(key, value), Insert the value in the cache if the key is not already present or update the value of the given key if the key is already present. When the cache reaches its capacity, it should invalidate the least recently used item before inserting the new item.
You will be given ‘Q’ queries. Each query will belong to one of these two types:
Type 0: for get(key) operation.
Type 1: for put(key, value) operation.
Note :
1. The cache is initialized with a capacity (the maximum number of unique keys it can hold at a time).

2. Access to an item or key is defined as a get or a put operation on the key. The least recently used key is the one with the oldest access time.
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
3084 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Amazon
2294 views
1 comments
0 upvotes
company logo
SDE - 1
3 rounds | 6 problems
Interviewed by Amazon
1592 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
58237 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