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

SDE - 1

Amazon
upvote
share-icon
4 rounds | 7 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 2 months
Topics: Data Structures, OOPS, Algorithms, Dynamic Programming, Operating system, cs fundamentals
Tip
Tip

Tip 1 : Use Geekforgeeks, interviewbit, leetcode
Tip 2 : Stay focused and regular
Tip 3 : Revise your concepts

Application process
Where: Other
Eligibility: 1+ Year experience
Resume Tip
Resume tip

Tip 1 : Short and crisp, do not add anything fake. prepare everything you mentioned in resume.
Tip 2 : Add good project

Interview rounds

01
Round
Easy
Online Coding Interview
Duration60 minutes
Interview date24 Mar 2022
Coding problem2

It has 2 coding questions and some behavioural questions.

1. Minimum Cost to Destination

Hard
41m average time
30% success
0/120
Asked in companies
AmazonOYOBarclays

You have been given an N*M matrix where there are 'N' rows and 'M' columns filled with '0s' and '1s'.


'1' means you can use the cell, and '0' means the cell is blocked. You can move in the 4 following directions from a particular position (i, j):

1. Left - (i, j-1)
2. Right - (i, j+1)
3. Up - (i-1, j)
4. Down - (i+1, j)

Now, for moving in the up and down directions, it costs you $1, and moving to the left and right directions are free of cost.

You have to calculate the minimum cost to reach (X, Y) from (0, 0) where 'X' is the row number and 'Y' is the column number of the destination cell. If it is impossible to reach the destination, print -1.

Problem approach

solved using dijiksra single source all path algorithm to mind minimum cost.

Try solving now

2. Minimum Operations

Easy
20m average time
82% success
0/40
Asked in companies
BNY MellonLinkedInThought Works

You are given an array 'ARR' of 'N' positive integers. You need to find the minimum number of operations needed to make all elements of the array equal. You can perform addition, multiplication, subtraction or division with any element on an array element.

Addition, Subtraction, Multiplication or Division on any element of the array will be considered as a single operation.

Example:

If the given array is [1,2,3] then the answer would be 2. One of the ways to make all the elements of the given array equal is by adding 1 to the array element with value 1 and subtracting 1 from the array element with value 3. So that final array would become [2,2,2]. 
Problem approach

1.Multiply by 2, i.e., do m = 2 * m
2.Subtract 1, i.e., do m = m – 1

Try solving now
02
Round
Medium
Video Call
Duration60 minutes
Interview date5 Apr 2022
Coding problem2

It was online face to face round

1. K Most Frequent Elements

Moderate
10m average time
85% success
0/80
Asked in companies
FacebookOracleAmazon

You are given an Integer array ‘ARR’ and an Integer ‘K’.


Your task is to find the ‘K’ most frequent elements in ‘ARR’. Return the elements in any order.


For Example:

You are given ‘ARR’ = {1, 2, 2, 3, 3} and ‘K’ = 2. 

The answer will {2, 3} as 2 and 3 are the elements occurring most times.
Problem approach

solved using hashmap
1.Create a Hashmap hm, to store key-value pair, i.e. element-frequency pair.
2.Traverse the array from start to end.
3.For every element in the array update hm[array[i]]++
4.Store the element-frequency pair in a vector and sort the vector in decreasing order of frequency.
5.Print the first k elements of sorted array.

Try solving now

2. House Robber

Moderate
26m average time
0/80
Asked in companies
PayPalExpedia GroupGoldman Sachs

A thief wants to loot houses. He knows the amount of money in each house. He cannot loot two consecutive houses. Find the maximum amount of money he can loot.

Problem approach

1. Create an extra space dp, DP array to store the sub-problems.
2.Tackle some basic cases, if the length of the array is 0, print 0, if the length of the array is 1, print the first 
. element, if the length of the array is 2, print maximum of two elements.
3. Update dp[0] as array[0] and dp[1] as maximum of array[0] and array[1]
4. Traverse the array from the second element (2nd index) to the end of array.
5. For every index, update dp[i] as maximum of dp[i-2] + array[i] and dp[i-1], this step defines the two 7.
cases, if an element is selected then the previous element cannot be selected and if an element is not selected then the previous element can be selected.
6. Print the value dp[n-1]

Try solving now
03
Round
Easy
Video Call
Duration60 minutes
Interview date7 Apr 2022
Coding problem2

It was 2nd problem solving round

1. Unique Paths II

Hard
0/120
Asked in companies
MicrosoftAmazon

Robot is given a task to clean a room. The room can be visualized as a matrix ‘ARR’ containing ‘N’ rows and ‘M’ columns. The cells of the room are denoted as:

1) Cells with a value of 0 indicate empty space in the room.
2) Cells with a value of -1 indicate an obstacle in the room.
3) Cell with a value of 1 indicates the starting position of the robot.
4) Cell with a value of 2 indicates the ending position of the robot.

In each move, the robot is only allowed to move to one of the four adjacent cells if it exists and is not occupied by an obstacle. Robot has to clean this room entirely. To complete this task his path must start from his starting cell and should visit all the empty cells (denoted by value 0) exactly once, and he should finally arrive at the ending cell. You have to find the number of all possible paths using which the robot can clean the room.

Note that the cells corresponding to the starting and ending position of the robot are never occupied by an obstacle. And starting and ending positions will always be in different cells.

For Example :
If ‘N’ = 3, ‘M’ = 3 and ‘ARR’ = [ [1, 0, 0], [0, 0, 0], [0, 0, 2] ]

Then the room is represented as:

The 2 unique paths are marked in the image above.
The first path is: (0, 0) -> (0, 1) -> (0, 2) -> (1, 2) -> (1, 1) -> (1, 0) -> (2, 0) -> (2, 1) -> (2, 2).

The second path is: (0, 0) -> (1, 0) -> (2, 0) -> (2, 1) -> (1, 1) -> (0, 1) -> (0, 2) -> (1, 2) -> (2, 2).
Problem approach

Used Bottom up DP
1. Create a 2D matrix of the same size as the given matrix to store the results.
2. Traverse through the created array row-wise and start filling the values in it.
3. If an obstacle is found, set the value to 0.
4. For the first row and column, set the value to 1 if an obstacle is not found.
5. Set the sum of the right and the upper values if an obstacle is not present at that corresponding position in the given matrix
6. Return the last value of the created 2d matrix

Try solving now

2. Copy List with Random Pointer

Easy
10m average time
90% success
0/40
Asked in companies
MicrosoftUrban Company (UrbanClap)Amazon

Given a linked list having two pointers in each node. The first one points to the next node of the list, however, the other pointer is random and can point to any node of the list or null. The task is to create a deep copy of the given linked list and return its head. We will validate whether the linked list is a copy of the original linked list or not.

A deep copy of a Linked List means we do not copy the references of the nodes of the original Linked List rather for each node in the original Linked List, a new node is created.

For example,

example

Random pointers are shown in red and next pointers in black.

Problem approach

1. Create the copy of node 1 and insert it between node 1 & node 2 in the original Linked List, create a copy of 2 and insert it between 2 & 3. Continue in this fashion, add the copy of N after the Nth node 
2. Now copy the random link in this fashion
3. This works because original->next is nothing but a copy of the original and Original->random->next is nothing but a copy of the random.
4. Now restore the original and copy linked lists in this fashion in a single loop.
5. Ensure that original->next is NULL and return the cloned list.

Try solving now
04
Round
Medium
Video Call
Duration60 minutes
Interview date15 Apr 2022
Coding problem1

It was bar raiser round and only one coding question was asked along with some behavioural question

1. Edit Distance

Moderate
30m average time
70% success
0/80
Asked in companies
OYOGoldman SachsHCL Technologies

You are given two strings 'S' and 'T' of lengths 'N' and 'M' respectively. Find the "Edit Distance" between the strings.

Edit Distance of two strings is the minimum number of steps required to make one string equal to the other. In order to do so, you can perform the following three operations:

1. Delete a character
2. Replace a character with another one
3. Insert a character
Note:
Strings don't contain spaces in between.
Problem approach

1. first tried using recursion which was exponential in complexity
2. Optimized and Solved using 2d array and dynamic programming/ bottom up approach.

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
8963 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
5984 views
5 comments
0 upvotes