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: 6 months
Topics: Dynamic programming, Algorithms, OOPS, Data Structures, Operating System
Tip
Tip

Tip 1 : Listen carefully to what the interviewer expects from you. 
Tip 2 : Practice at least 300 questions, topic wise.
Tip 3 : Do participate in contests.

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

Tip 1 : Be true on your resume.
Tip 2 : Make your resume crisp and clear.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration90 minutes
Interview date24 May 2020
Coding problem2

1. String Transformation

Moderate
23m average time
0/80
Asked in companies
WalmartSprinklrAccenture

Given a string (STR) of length N, you have to create a new string by performing the following operation:

Take the smallest character from the first 'K' characters of STR, remove it from STR and append it to the new string.

You have to perform this operation until STR is empty.

 Note:
The input string(STR) will not contain any spaces.

Assume that all characters in STR are lower case letters.

If characters less than 'K' remain, then append them in a sorted way to the new string.
Example:
Let the input string be "edcba" with K = 4.

Let the new string to be formed is initially empty, newString = "".
The first set of 4 characters are, ('e', 'd', 'c', 'b')
Out of these 4 characters, the smallest one is 'b' and hence we add it to the newString and it becomes, 
newString = "b"

The next set of 4 characters are, ('e', 'd', 'c', 'a')
Out of these 4 characters, the smallest one is 'a' and hence we add it to the newString and it becomes, 
newString = "ba"

Now we are left with "edc" and since we can't get a window of size 4, we sort them in the increasing order and append them to the newString.

Hence, newString thus formed will be "bacde".
Problem approach

I solved it using brute force. 

Try solving now

2. Count derangements

Moderate
35m average time
60% success
0/80
Asked in companies
AmazonInfo Edge India (Naukri.com)Cisco

A Derangement is a permutation of ‘N’ elements, such that no element appears in its original position. For example, an instance of derangement of {0, 1, 2, 3} is {2, 3, 1, 0}, because 2 present at index 0 is not at its initial position which is 2 and similarly for other elements of the sequence.

Given a number ‘N’, find the total number of derangements possible of a set of 'N’ elements.

Note:
The answer could be very large, output answer %(10 ^ 9 + 7).
Problem approach

I had already done this question using memoisation.

Try solving now
02
Round
Medium
Video Call
Duration60 minutes
Interview date21 Jun 2020
Coding problem4

1 hour online interview. 
Slot was given prior via email.
The HR contacted me via email and simultaneously provided me a link where I had to write the codes during my interview

1. Mike and Mobile

Moderate
35m average time
45% success
0/80
Asked in companies
AmazonFacebookUber

Mike is a little boy who loves solving math problems. One day he was playing with his mom’s mobile. The mobile keypad contains 12 buttons { 10 digits(0-9) and 2 characters(‘*’ and ‘#’) }. Mike wants to know how many different numbers he can generate after pressing exactly the 'N' buttons on the keypad. Mike presses the buttons with the following rules:

1. He always presses the button which has a digit written on it, i.e., he never presses the ‘*’ and ‘#’ button.
2. Once he presses a button, the next button he presses should either be the same button or the button which is adjacent to the previous button.
3. In starting he can press any button except ‘*’ and ‘#’.

mobile

Mike is too little to solve this problem. Help Mike to solve this problem. As the answer can be large, so find the answer modulo 10^9 + 7.

Try solving now

2. Maximum Subarray Sum

Moderate
25m average time
75% success
0/80
Asked in companies
Paytm (One97 Communications Limited)AmazonSnapdeal

Given an array of numbers, find the maximum sum of any contiguous subarray of the array.


For example, given the array [34, -50, 42, 14, -5, 86], the maximum sum would be 137, since we would take elements 42, 14, -5, and 86.


Given the array [-5, -1, -8, -9], the maximum sum would be -1.


Follow up: Do this in O(N) time.

Problem approach

1. I explained the Naive approach which was taking 2 loops and considering every subarray once. It was an O(N^2 ) approach.
2. I optimised my approach to one loop making it O(N), by applying kadane algorithm.

Try solving now

3. Maximum sum of non-adjacent elements

Moderate
15m average time
85% success
0/80
Asked in companies
OYOOLX GroupWalmart

You are given an array/list of ‘N’ integers. You are supposed to return the maximum sum of the subsequence with the constraint that no two elements are adjacent in the given array/list.

Note:
A subsequence of an array/list is obtained by deleting some number of elements (can be zero) from the array/list, leaving the remaining elements in their original order.
Problem approach

1. I solved it in O(N) time.
2. The interviewer asked me to dry run it so as to rectify a few mistakes I made.
3. I resolved the issues.

Try solving now

4. Trapping Rainwater

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

1. I used every possible combination, O(N^2).
2. I then optimised it using 2 pointers, O(N).

Try solving now
03
Round
Medium
Video Call
Duration60 minutes
Interview date23 Jul 2020
Coding problem2

1. Strongly Connected Components (Tarjan’s Algorithm)

Hard
15m average time
85% success
0/120
Asked in companies
AppleMicrosoftAmazon

You are given an unweighted directed graph of 'V' vertices and 'E' edges. Your task is to print all the strongly connected components (SCCs) present in the graph.

Problem approach

I applied Depth first search for exploring all the components. The interviewer was happy with that approach.

Try solving now

2. Selling Stock

Moderate
22m average time
0/80
Asked in companies
Phone PeAmazonFacebook

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.

 Note :
You may make as many transactions as you want but can not have more than one transaction at a time i.e, if you have the stock, you need to sell it first, and then only you can buy it again.
Problem approach

This is a famous problem named Stock buy and sell. I did it in O(N) time and constant extra space.

Try solving now
04
Round
Easy
Video Call
Duration60 minutes
Interview date29 Jul 2020
Coding problem2

This was a one hour round in which I was first told to introduce myself and then moved to questions.

1. Permutation in String

Hard
20m average time
80% success
0/120
Asked in companies
IBMMicrosoftAmazon

You have been given two strings ‘str1’ and ‘str2’ of length N and M respectively. Your task is to check whether string ‘str2’ contains one of the permutations of string ‘str1’ as its substring.

In other words, find whether there exists any permutation of string ‘str1’ that is a substring of ‘str2’.

A string ‘x’ is a permutation of another string ‘y’ only if sorted(x) = sorted(y). For example, LISTEN is a permutation of SILENT.

Note: ‘str1’ and ‘str2’ contains only lowercase English Alphabet letters.

For Example :

Input: str1 = “ab” , str2 = “aoba”
Output: Yes

Explanation: Permutations of first-string str1 i.e. “ab” are [“ab”, “ba”].
The substrings of str2, i.e. “aoba” are [“a”, “o”, “b”, “a”, “ao”, “ob”, “ba”, “aob”, “oba”, “aoba”].
The string “ba” is present in the list of substrings of string str2.
Problem approach

1. Firstly, I gave the brute force approach in which I one by one checked every character of string 1 in string 2
2. I then optimised it using the unordered map to store frequency of each character.

Try solving now

2. Sort 0 1 2

Easy
22m average time
0/40
Asked in companies
HCL TechnologiesWalmartOptum

You have been given an integer array/list(ARR) of size 'N'. It only contains 0s, 1s and 2s. Write a solution to sort this array/list.

Note :
Try to solve the problem in 'Single Scan'. ' Single Scan' refers to iterating over the array/list just once or to put it in other words, you will be visiting each element in the array/list just once.
Problem approach

1. Firstly, I did it using 3 variables which stored the count of 1, 2 and 3.
2. My interviewer asked me to optimise and then, I did it using 2 pointers.

Try solving now
05
Round
Medium
Video Call
Duration60 minutes
Interview date10 Aug 2020
Coding problem1

This was based more on my communication skills rather than my technical skills. The interviewer didn't only focus on whether I knew the answer or not but if I was able to communicate my knowledge to the interviewer.

It was more of theory based interview
Questions are as follows:-
1. What are SQL and acid properties?

2. How does a website start?

3. What are deadlocks with real life examples? Give necessary conditions for deadlock. 
-> Real life examples were must. 

4. What is virtual function?

5. Tell me the most challenging this while you made your project. ( I had to pick my project on my own) 

6. Tell me the most interesting feature you found working on a language. 

7. Technical question on structures in C as I used it in my project. The interviewer asked if the structure for a linked list is changed as:-
struct node

{
int data;
struct next; 
};
I explained how this won't work as struct will be created again and again which will lead to memory limit exceeded.

1. Delete alternate nodes

Easy
20m average time
80% success
0/40
Asked in companies
Morgan StanleyTata Consultancy Services (TCS)Amazon

Given a Singly Linked List of integers, delete all the alternate nodes in the list.

Example:
List: 10 -> 20 -> 30 -> 40 -> 50 -> 60 -> null
Alternate nodes will be:  20, 40, and 60.

Hence after deleting, the list will be:
Output: 10 -> 30 -> 50 -> null
Note :
The head of the list will remain the same. Don't need to print or return anything.
Problem approach

1. I gave an approach in which I reversed the whole linked list and then reversed every word.
2. Time complexity was thoroughly discussed and my interviewer was happy with my 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 create a function in JavaScript?

Choose another skill to practice
Start a Discussion
Similar interview experiences
company logo
SDE - 1
3 rounds | 5 problems
Interviewed by Amazon
1141 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Amazon
1315 views
1 comments
0 upvotes
company logo
SDE - 1
3 rounds | 6 problems
Interviewed by Amazon
569 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Amazon
2301 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
50692 views
5 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Samsung
11258 views
2 comments
0 upvotes
company logo
SDE - 1
2 rounds | 4 problems
Interviewed by Google
9921 views
0 comments
0 upvotes