# Amazon Interview Experience | SDE-1 (1-1.5 years experienced)

Last Updated : 09 Dec, 2019

First Try:

Round 1: Written test.

Q1. given a matrix of characters. find minimum steps to reach from ‘S’ to ‘D’ where ‘#’ is an obstacle.

Solution: BFS from ‘S’ to ‘D’.

Q2. print a binary tree vertically.Â link

Round 2: f2f interview.

Q1. given a binary tree print the nodes whose parent and grandparents sum is more than K.

Solution: pass GP and parent in recursion call.

Q2. modified the above question to print the nodes whose N parents sum is more than K.

Solution: recursion with a sum vector to calculate the sum in O(1) for any node.

Round 3: f2f interview.

Q1. given an Array print min and max of each subarray of size K.

he modified the question to find median as well.

Solution: 2 heaps approach link. he insisted on optimizing more by re-using the calculated data while finding min and max but I couldn’t.

Q2. given a Binary Tree and a pointer to one of its Node. at any point of time, this Node starts burning and the fire takes 1 second to reach an adjacent node. Print the nodes which will be burnt on each second separated by a newline.

Solution: find k distance nodes.Â link

I called such function while increasing the k value each time. he asked to do it in O(N) which I couldn’t.

later I thought I should have created a map of distance and nodes in a single function call.

I was called again next week.

Round 4:Â f2f interview. (this round was taken by mistake as they though It was my first round)

Q1. find the min replacements needed to convert string 1 to string 2.

Q2. the next greater elements.

Round 5:Â f2f hiring manager.

Q1. design an elevator system.

Solution: I was more focused on writing code than designing interfaces for all components of the lift.

I’ll advise learning the way of answering such questions like class diagrams and then focus on design patterns.

Q2. median of a stream of numbers.

Solution: 2 heap approach.

Result:Â Rejected.

Second Try:

Round 1: Written test(solve 2/3)

Q1.Â find zeroes to be flipped so that number of consecutive 1s is maximized.Â Â link

Q2. sort the array when an index x can only be swapped with x+k. if not possible return -1.

Q3. print the numbers having same digits, together. similarÂ link

Round 2:Â f2f.

Q1. k most frequent strings in a book.

Solution: described Hash-Heap andÂ Trie-Heap approach and was asked to code Hash one.

Q2. count number of subarrays having the sum equal to K.Â Â link

Round 3: f2f.

Q1. search element in the row-wise, column-wise sorted matrix.Â link

Q2. Maximum path sum in BT.Â link

Round 4: f2fÂ hiring manager.

Detailed discussion on my current Project.

Round 5: OnlineÂ bar-raiser.

any project/task that I am most proud of.

Q: he shared a linkÂ to a 30-second youtube video. describing the amazon lockers system. where a delivery guy puts the package in locker. the customers scan the locker and get their package. design the schema and write an efficient algorithm to help find the appropriate locker for the delivery guy.

Solution:

Schema: lockers -> Racks -> Locations.

Algo: having queues for each locker size on every location.

Result:Â selected.

Previous
Next