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

# SDE - 1

Amazon
5 rounds | 9 Coding problems

## Interview preparation journey

Journey
I am from cse background. In the college last , I joined coding ninjas c++ course for preparation. This course helped me in understanding basics of language and syntax. After this course i am able to crack multiple companies. During my preparation i followed leetcode and some youtube courses.
Application story
Amazon visited our campus for placements. There were total 5 round in the interview. Application was done through placement cell of our college and the process was very smooth.
Why selected/rejected for the role?
I was selected in the interviews as I had prepared well. Also I did not lose my confidence when I saw others losing hope.
Preparation
Duration: 4 months
Topics: Data structures and Algorithms, Computer fundamentals subjects. Basics of every skill that you have written in your resume and also knowledge of concepts related to your projects. You should know whatever you have written in your resume.
Tip

Don’t create panic in any case in the interview , as even if you are not selected you will learn a lot from your interview experience and perform well in the future. Also I would recommend you Coding Ninjas as according to me it is a good platform to learn basic coding concepts and to practice coding.

Application process
Where: Campus
Eligibility:
Resume tip

Write whatever you are sure about and have actually done that. CGPA plays a good role but not a complete role as it is just eligibility criteria for some companies. Have at least 1 or 2 good projects from which you know everything involved in the project.

## Interview rounds

01
Round
Easy
Online Coding Test
Duration90 minutes
Interview date2 Aug 2019
Coding problem2

This round consist of two questions and we have to solve both the questions to qualify for the next round.

### 1. Occurrence of X in a Sorted Array

Moderate
26m average time
0/80

Count number of occurrences (or frequency) in a sorted array

Given a sorted array arr[] and a number x, write a function that counts the occurrences of x in arr[].

Examples:

Input: arr[] = {1, 1, 2, 2, 2, 2, 3,},   x = 2

Output: 4
2 occurs 4 times in arr[]

Problem approach
• Linear search solution was not working there as they are expecting less than O(n) complexity, so I solved this using binary search by finding the first and the last occurrence of element and subtracting them which will give the required answer.

### 2. Maximum In Subarray

Easy
27m average time
0/40

Given an array and an integer K, find the maximum for each and every contiguous subarray of size k.

Examples :

Input: arr[] = {1, 2, 3, 1, 4, 5, 2, 3, 6}, K = 3

Output: 3 3 4 5 5 5 6

Explanation:

Maximum of 1, 2, 3 is 3

Maximum of 2, 3, 1 is 3

Maximum of 3, 1, 4 is 4

Maximum of 1, 4, 5 is 5

Maximum of 4, 5, 2 is 5

Maximum of 5, 2, 3 is 5

Maximum of 2, 3, 6 is 6

Problem approach
• In this question as constraints were high so simple brute force was not working so used Deque data structure to solve this question.
02
Round
Easy
Face to Face
Duration40 minutes
Interview date3 Aug 2019
Coding problem1

A single coding question was asked that had a lot of corner cases.

### 1. Convert given number to words

Moderate
24m average time
0/80

Convert a given number into words for news reading by a device.

Example :

If the given input is 62, the output should be 'Sixty two' (without quotes).

Problem approach
• The solution involved concepts like Hash Maps & arrays. I was asked to write down the complete code after discussing the approach with the interviewer. She read the complete code, ran through a test case and it worked on pen and paper.
03
Round
Easy
Face to Face
Duration45 minutes
Interview date3 Aug 2019
Coding problem3

It had 3 coding questions followed by basic concepts of DP.

### 1. Converting min heap to a max heap

Moderate
26m average time
0/80

Converting a min heap to a max heap. There can be multiple max heaps possible. Any max heap will be good.

Problem approach
• I just simply use the concept of building heap in given array which was in O(n) time complexity, so interviewer got satisfied by my approach.

### 2. Selling Stock

Moderate
22m average time
0/80

You have been given stock values/prices for N number of days. Every i-th day signifies the price of a stock on that day. Your task is to find the maximum profit which you can make by buying and selling the stocks.

Problem approach
• I gave him a brute force approach first and then told him a stack approach based on local maxima and minima.

### 3. Maximum difference between a node and its descendent

Moderate
24m average time
0/80

To find the maximum difference between a node and its descendent in the same path in the binary tree.

Problem approach
• I was a little confused in this question but then thought of using recursion so gave interviewer tree traversal solution using recursion by calculating minimum from left and right subtree and keeping the maximum difference in answer variable.
04
Round
Easy
Face to Face
Duration30 minutes
Interview date3 Aug 2019
Coding problem2

It had 2 coding questions which were of good level.

### 1. Implementation: HashMap

Easy
30m average time
90% success
0/40

Implement a data structure that can perform insertion, deletion, searching in constant time.

Problem approach
• I implemented hashmap using hashing with chaining technique which I already prepared before the interview.

### 2. Kruskal’s Minimum Spanning Tree Algorithm

Moderate
30m average time
80% success
0/80

Find an MST from a given graph by using Kruskal algorithm.

Problem approach
• I gave him the Kruskal algorithm solution. So he asked me to write the algorithm for that and to dry run that on a particular example. I gave him a crystal clear explanation with dry running it on a particular example.
05
Round
Easy
Face to Face
Duration30 minutes
Interview date3 Aug 2019
Coding problem1

This was the last round.

### 1. Sum Between Zeros

Easy
20m average time
80% success
0/40

You are given a Singly Linked List which contains a series of integers separated by ‘0’.

Between two zeroes, you have to merge all the nodes lying between them into a single node which contains the sum of all the merged nodes. You have to perform this in place.

Problem approach
• I gave approach by maintaining sum between all the zeros. Whenever i encounter a zero, i calculated the sum of all the elements that had come before the last zero. In parallel, i keep changing the linked list as well.

Here's your problem of the day

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

What does ROLLBACK do in DBMS?

Join the Discussion
2 replies
10 Aug 2022
Comment Removed
0 replies
Rakesh |Level 2
9 Sep 2021
Comment Removed
0 replies
Similar interview experiences
SDE - 1
3 rounds | 5 problems
Interviewed by Amazon
854 views
SDE - 1
4 rounds | 8 problems
Interviewed by Amazon
1138 views
SDE - 1
3 rounds | 6 problems
Interviewed by Amazon
441 views
SDE - 1
4 rounds | 8 problems
Interviewed by Amazon
1287 views
Companies with similar interview experiences
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
49377 views