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

SDE - 1

Amazon
upvote
share-icon
4 rounds | 8 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 2 months
Topics: Data Structures , Algorithms, OOPS, Computer Networks, Data Base Management System , Operating Systems
Tip
Tip

Tip 1 : Practice all previous amazon interview questions
Tip 2 : Study Well about your projects about databases used and the reason they are used.

Application process
Where: Referral
Eligibility: NA
Resume Tip
Resume tip

Tip 1 : Well defined projects in resume
Tip 2 : Problem solving/Open source skills are a plus

Interview rounds

01
Round
Easy
Online Coding Interview
Duration90 Minutes
Interview date10 Jun 2021
Coding problem2

Online Coding Round

1. Shortest Path In A Binary Maze

Moderate
30m average time
75% success
0/80
Asked in companies
SamsungAmazonHSBC

Given a maze in the form of a binary rectangular matrix of size M*N, where each element can either be 0 or 1, the task is to find the length of the shortest path in a maze from a given source cell to a destination cell.

The path can only be created out of a cell if its value is 1 and at any given moment, we can only move one step in one of the four directions. The valid moves are:

Up: (x, y) -> (x - 1, y)
Left: (x, y) -> (x, y - 1)
Down: (x, y) -> (x + 1, y)
Right: (x, y) -> (x, y + 1)

If there is no path from a given source cell to a destination cell, return -1.

For example :
consider the binary matrix below. If source = (0, 0) and destination = (3, 4), the shortest path from source to destination has length 11.

example

Problem approach

Step 1 -> Start a BFS from the given source point
Step 2 -> Maintain a counter variable which holds the value of the level of BFS which is being investigated
Step 3-> When you reach the target cell point return the value of counter variable which will denote the shortest distance.
Step 4-> If target is not reached return -1 in the end after the BFS is completed

Try solving now

2. Connect N Ropes With Minimum Cost

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

You have been given 'N' ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. We need to connect the ropes with minimum cost.

The test-data is such that the result will fit into a 32-bit integer.

Problem approach

Step 1 -> Declare a Min Heap and push all the given rope lengths in it.
Step 2 -> Execute till the size of the Min Heap is greater than 2.
Step 3 -> At each step take the top most two entries from the Min Heap and add them to your cost.
Step 4 -> Also add the two min entries taken at some point back to Min heap as two ropes of size x and y when joined together creates a new rope of size x+y which can be used further.
Step 5 -> As it is a greedy approach using Min Heap , the total cost in minimized.

Try solving now
02
Round
Medium
Video Call
Duration60 minutes
Interview date21 Jul 2022
Coding problem2

Problem Solving and Data Structures round.

1. Anagram Pairs

Moderate
30m average time
60% success
0/80
Asked in companies
AdobeThought WorksHSBC

You are given two strings 'str1' and 'str1'.


You have to tell whether these strings form an anagram pair or not.


The strings form an anagram pair if the letters of one string can be rearranged to form another string.

Pre-requisites:

Anagrams are defined as words or names that can be formed by rearranging the letters of another word. Such as "spar" can be formed by rearranging letters of "rasp". Hence, "spar" and "rasp" are anagrams. 

Other examples include:

'triangle' and 'integral'
'listen' and 'silent'
Note:
Since it is a binary problem, there is no partial marking. Marks will only be awarded if you get all the test cases correct. 
Problem approach

Step 1-> Run two nested for loops to check for each pair (arr[i],arr[j]) are anagrams of each other or not.
Step 2-> For checking anagrams I used hashing where I counted frequency of each character if all the frequencies were same in both the string return true else return false that they are not anagrams.
Step 3 -> Grouped the pairs which matched that they are anagrams.

Extended Problem Solution:
When all the characters in each string were unique (not repeating)
Step 1 -> Try to think each word to be encoded as Binary.
Step 2 -> Say a string "abe" will look something like "00000000000000000000010011" where LSB to MSB tells us if 0th character , 1st character and so on appears or not. Note that it is 26 bit Binary Number as strings are given to have only lower case character.
Step 3-> Encode given strings into binary number and group all the strings who get the same encoding which can be further done using hashing.

Try solving now

2. Count Inversions

Moderate
40m average time
55% success
0/80
Asked in companies
Hewlett Packard EnterpriseBNY MellonGrab

For a given integer array/list 'ARR' of size 'N' containing all distinct values, find the total number of 'Inversions' that may exist.

An inversion is defined for a pair of integers in the array/list when the following two conditions are met.

A pair ('ARR[i]', 'ARR[j]') is said to be an inversion when:

1. 'ARR[i] > 'ARR[j]' 
2. 'i' < 'j'

Where 'i' and 'j' denote the indices ranging from [0, 'N').
Problem approach

First I gave a Brute force solution using two nested Loops and trying out all pairs, which Interviewer asked me to optimize.
I asked about the constraints of elements occurring in the array , it was given that each arr[i]<=10^5 
Step 1 -> Declare a Binary Indexed Tree of size equal to maximum element occurring in array 
Step 2- > Traverse array from end till start (N-1 index till 0) and at each step if the element currently is x , find prefix sum of BIT Tree till index x which will tell the number of smaller elements smaller than arr[i] in the right of it ( which exactly is the meaning of inversions).
Step 3 -> return the count of inversions at end.

Another Solution when arr[i]<=10^9
Using Merge Sort to count Inversions

Try solving now
03
Round
Medium
Video Call
Duration60 Minutes
Interview date4 Aug 2021
Coding problem1

DSA and Problem Solving

1. Minimum Window Subsequence

Hard
27m average time
0/120
Asked in companies
AmazonNagarro SoftwareTummee

You are given two strings ‘S’ and ‘T’. Your task is to find the minimum (Contiguous) substring ‘W’ of ‘S’, such that ‘T’ is a subsequence of ‘W’

A subsequence is a sequence that can be derived from another sequence by removing zero or more elements, without changing the order.

A substring is a contiguous part of a string.

For example:
For the given string “CodingNinjas”: “Ninja” is a substring while “dinas” is a subsequence. 

If there is no such Window in ‘S’ that covers all characters in ‘T’, return an empty string "". If there are multiple such minimum length windows, return the one with the smallest starting index.

Problem approach

Step 1 -> Gave a Brute force solution by trying out all substrings and building a check function to verify if current window has all characters of other string or not.
Step 2-> I was told to optimize it
Step 3-> Tried using hashing + sliding window
Step 4 -> was not able to code it up properly.
Step 5 -> Tried doing it using Binary search where start=Length of String B and end= String length of A and tried each substring of the chosed length ( mid=(start+end/2)).
Step 6 -> was an overkill for the problem so Interviewer wanted me to focus on hashing + sliding window

Try solving now
04
Round
Easy
Video Call
Duration75 Minutes
Interview date26 Aug 2021
Coding problem3

Deep discussions about projects about the tech stack used and why it is used . In depth subject questions .

1. System Design Question

What is LRU cache and how it is implemented.?

Problem approach

Tip 1 : For such questions , you can't come up with the best solution during an interview try to give two three iterations of practice of coding/understanding during preparation.
Tip 2 : Try to make small notes for fast revision.

2. DBMS Questions

Difference between NOSQL and SQL DataBases , in what scenario we should used SQL and NoSQL?

Problem approach

Tip 1 : Have a good understanding of projects implemented and the choice of data base for the problem you are solving.
Tip 2 : Make notes for quick revision.

3. Operating System Questions

What are semaphores , What are mutexes , explain difference between them, What is multithreading , explain a scenario where you may need multithreading?

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