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

SDE - 1

Amazon
upvote
share-icon
5 rounds | 11 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: Linked Lists, Trees, BFS, DFS, Backtracking, Graphs.
Tip
Tip

Tip 1 : Practice at least 250 Questions, Give yourself enough time for preparation. Cramming won't take you very far. In books, I really liked Elements of Programming Interviews. 
Tip 2 : Make sure to brush up your basics - coding style, OOPs, Language features. They help in making an impression.
Tip 3 : Don't worry about solving the question in the interview. Learn to tackle any random problem with the best of your ability. More often than not, that'd be enough.

Application process
Where: Campus
Eligibility: No criteria
Resume Tip
Resume tip

Tip 1 : Keep your resume clean - no graphics, no multiple fonts. Keep it one page.
Tip 2 : Don't go over board in mentioning skills, only mention the things you are truly confident about.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration90 minutes
Interview date12 Jul 2019
Coding problem1

 Around 65-70 people sat for the test. 15 people were shortlisted. It consisted of the following to be done in 90 minutes.

- 28 MCQs based on core CS 

- 2 Coding questions – everyone had different and random questions. Most questions were custom logic based (easy level) including some standard questions – LCS, LIS, topological sort.

1. MCQ Questions

28 MCQs based on core CS – trees, BFS, DFS, C++ outputs, stacks, queues. If you’ve prepared for placements, you’ll get through them pretty easily. If unprepared, it will be challenging to go through them within the allotted time.

02
Round
Easy
Face to Face
Duration60 minutes
Interview date19 Jul 2019
Coding problem2

Interviewer was very friendly. It started with the standard – tell me about yourself / introduce yourself type of question. Then he proceeded and asked two coding questions

1. Remove Duplicates from Sorted List

Easy
0/40
Asked in companies
AdobeAppleAmazon

A doubly-linked list is a data structure that consists of sequentially linked nodes, and the nodes have reference to both the previous and the next nodes in the sequence of nodes.


You are given a sorted doubly linked list of size 'n'.


Remove all the duplicate nodes present in the linked list.


Example :
Input: Linked List: 1 <-> 2 <-> 2 <-> 2 <-> 3

Output: Modified Linked List: 1 <-> 2 <-> 3

Explanation: We will delete the duplicate values ‘2’ present in the linked list.


Problem approach

Pretty Straightforward. Standard linked list question. I discussed approach with the interviewer. Then coded out the solution.

Try solving now

2. Course Schedule

Easy
15m average time
85% success
0/40
Asked in companies
UberAppleDunzo

You are a student of Netaji Subhas Institute of Technology. You have to take ‘N’ number of courses labelled from 1 to N to complete your B.Tech Degree.

Some courses may have prerequisites, for example, to take course 1 you have to first take course 2, which is expressed as a pair: [1, 2]. Now, your task is to find is it possible for you to finish all courses.

Note: There are no duplicate pairs in the prerequisites array.

For example-
If N = 2 and prerequisite = [[1, 2]]. Then, there are a total of 2 courses you need to take. To take course 1 you need to finish course 2. So, it is possible to complete all courses. 
Problem approach

I clarified in which format is the input, output, etc as it is a graph based problem.

This is a standard topological sort problem. I first explained overall approach then coded them on paper.

Try solving now
03
Round
Medium
Face to Face
Duration60 minutes
Interview date19 Jul 2019
Coding problem1

This round had only 1 question. The interviewer introduced himself. And he advised me to clearly understand the problem before proceeding.

1. LCA Of Binary Tree

Moderate
10m average time
90% success
0/80
Asked in companies
GrabDisney + HotstarShareChat

You have been given a Binary Tree of distinct integers and two nodes ‘X’ and ‘Y’. You are supposed to return the LCA (Lowest Common Ancestor) of ‘X’ and ‘Y’.


The LCA of ‘X’ and ‘Y’ in the binary tree is the shared ancestor of ‘X’ and ‘Y’ that is located farthest from the root.


Note :
You may assume that given ‘X’ and ‘Y’ definitely exist in the given binary tree.
For example :
For the given binary tree

Example

LCA of ‘X’ and ‘Y’ is highlighted in yellow colour.
Problem approach

Since this was a new question for me, I tried to stay calm and decided to tackle the problem to the best of my ability without thinking about the end solution. I started building on observations - heap like structure of tree, resemblance to lowest common ancestor.

The solution was as follows - 

- To count nodes in path, we find lowest common ancestor. Then we can use that ancestor to reach our input nodes, and count the black nodes in path.
- How can we find the lowest common ancestor? Since it is a heap like structure, i can get the parent node number using mathematical formula like heap. Now i have sort of a way to reach the parent.
- The problem decomposed to finding lowest common ancestor using these parent links. Then i reached the parent.
- And so on.

Took me around 30-40 minutes maybe. Then I coded it on paper. The code was hardly 10 lines surprisingly.

Try solving now
04
Round
Medium
Face to Face
Duration60 minutes
Interview date19 Jul 2019
Coding problem5

Pretty Good Round. Fast Paced. We covered a lot of ground.

1. BST Iterator

Moderate
20m average time
65% success
0/80
Asked in companies
AmazonSalesforceFacebook

You are given a class named as BSTIterator that represents an iterator over inorder traversal of a binary search tree. You need to implement the following things as follows:

1. BSTIterator(Node root) - It is a parameterized constructor in which you are given the root of the Binary search tree. It will be called whenever an object of BSTIterator is created.

2. next() - This member function will return the next smallest element in the in-order traversal of the binary search tree. You need to implement this function.

3. hasNext() - This function will return true if there exists the next smallest element in the traversal else it will return false. You need to implement this function

The binary search tree has ‘N’ nodes you need to print the inorder traversal of the tree using the iterator.

Problem approach

I engaged the interviewer. Established that we'll need controlled inorder traversal. That will need iteration, and we'll abstract it in a class. 

For this question, it's important that you are well versed with iterative solution of tree traversals. It's very hard to come up with a clean code for iterative traversal on the spot.

Try solving now

2. Maximum Consecutive Ones

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

Given a binary array 'ARR' of size 'N', your task is to find the longest sequence of continuous 1’s that can be formed by replacing at-most 'K' zeroes by ones. Return the length of this longest sequence of continuous 1’s.

Problem approach

I explained that a sliding window approach would work. The approach was easy, discussed it with interviewer. Then coded the solution.

Try solving now

3. BFS in Graph

Easy
10m average time
90% success
0/40
Asked in companies
Morgan StanleySamsung R&D InstituteRubrik, Inc.

Given an adjacency list representation of a directed graph with ‘n’ vertices and ‘m’ edges. Your task is to return a list consisting of Breadth-First Traversal (BFS) starting from vertex 0.


In this traversal, one can move from vertex 'u' to vertex 'v' only if there is an edge from 'u' to 'v'. The BFS traversal should include all nodes directly or indirectly connected to vertex 0.


Note:
The traversal should proceed from left to right according to the input adjacency list.


Example:
Adjacency list: { {1,2,3},{4}, {5}, {},{},{}}

The interpretation of this adjacency list is as follows:
Vertex 0 has directed edges towards vertices 1, 2, and 3.
Vertex 1 has a directed edge towards vertex 4.
Vertex 2 has a directed edge towards vertex 5.
Vertices 3, 4, and 5 have no outgoing edges.

We can also see this in the diagram below.

BFS traversal: 0 1 2 3 4 5

example

Problem approach

Standard BFS of a graph. Interviewer was just checking my skill in graphs. Coded on paper.

Try solving now

4. Dijkstra's shortest path

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

You have been given an undirected graph of ‘V’ vertices (labeled 0,1,..., V-1) and ‘E’ edges. Each edge connecting two nodes (‘X’,’Y’) will have a weight denoting the distance between node ‘X’ and node ‘Y’.

Your task is to find the shortest path distance from the source node, which is the node labeled as 0, to all vertices given in the graph.

Example:

Input:
4 5
0 1 5
0 2 8
1 2 9
1 3 2
2 3 6

alt text

In the given input, the number of vertices is 4, and the number of edges is 5.

In the input, following the number of vertices and edges, three numbers are given. The first number denotes node ‘X’, the second number denotes node ‘Y’ and the third number denotes the distance between node ‘X’ and ‘Y’.

As per the input, there is an edge between node 0 and node 1 and the distance between them is 5.

The vertices 0 and 2 have an edge between them and the distance between them is 8.
The vertices 1 and 2 have an edge between them and the distance between them is 9.
The vertices 1 and 3 have an edge between them and the distance between them is 2.
The vertices 2 and 3 have an edge between them and the distance between them is 6.

Note:

1. There are no self-loops(an edge connecting the vertex to itself) in the given graph.

2. There can be parallel edges i.e. two vertices can be directly connected by more than 1 edge.
Problem approach

I tried to tackle the problem with every graph algorithm i knew. After some struggle, he hinted to expand the weights, then the problem broke down to BFS. 

It was a little unusual problem. We just discussed this, no code.

Try solving now

5. DBMS Questions

A couple of DBMS questions - 

- What database have you worked on.
- Can you tell me what normal forms are?
- Can you explain me a few normal forms 
- Diff between sql and nosql
- Example of nosql databases? Example of nosql databases of amazon

Problem approach

Tip 1 : Sharpen your basics before the interview day. Go through tutorial point subjects on DBMS, OS, Networks

05
Round
Hard
Face to Face
Duration60 minutes
Interview date19 Jul 2019
Coding problem2

Bar Raised Round. Definitely felt the difficulty.

1. System Design Questions

The interviewer’s style was very different from others. Discussion started as follows -

- Tell me about yourself
- Tell me your best project from resume
- What did you do in this
- How is it different from any other similar project
- How did you assure code quality in your project
- How do you define code quality
- How did you test your code
- Did you write test cases for your code
- Write down test case for this code ( he gave a code )

He took each point very seriously, and did counter arguments for some of these.

- Then he asked me which app do I use for music.
- Lets design a database for an app.
- So I wrote a basic schema. He then picked up on the details. A bit of discussion.
- Then we moved to a specific table.
- Why is this table like this
- Do you think that app uses it like this
- Do you think its scalable
- What can you do to make it scalable
- What should you do to make it scalable
- Think about more use cases, develop a generic db structure which can accommodate some of future changes.
- A little discussion about development methodologies - ( plan a lot of use cases and then make database schema ) or ( deliver fast and re-iterate ).

Problem approach

Tip 1 : Stay calm under the pressure. It's okay to not know the correct solution to every question.

2. First non repeating character

Easy
15m average time
80% success
0/40
Asked in companies
QuikrHCL TechnologiesMakeMyTrip

Ninja is now bored with numbers and is now playing with characters but hates when he gets repeated characters. Ninja is provided a string, and he wants to return the first unique character in the string.The string will contain characters only from the English alphabet set, i.e., ('A' - 'Z') and ('a' - 'z'). If there is no non-repeating character, print the first character of the string. If there is no non-repeating character, return the first character of the string.

Problem approach

I tried tackling the problem through various angles. Was able to make a minor dent in the problem.

We just discussed the approach. No code.

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