Amazon Phone Screen SDE - II

1733
Jun 06, 2024

Coding:
Given grid's dimensions (m and n) and a list of lockers(cooridnates) return a grid[m][n] where every cell represents the euclidean distance to its nearest lockers.

Example
m = 2, n= 2, listofLockers = [[1,2]]

Output:
[[1.4,1]
[1, 0]]

My Approach:
BFS - insert all lockers into queue. perform traversal in all 4 directions and update distance.
Queue contains int[4] where first 2 values represent current cell and last values represent locker co-ordinates

Interviewer interrupted and mentioned it was brute force and wanted to come up with an optimal approach. (He gave me concentric circles approach as a hint which I did not know.)

LP -
Biggest obstacle you have ever faced?

YOE:3.5, Location: Seattle

P.S - Feeling disappointed after working hard, that I was asked something completely out of the box. I had a lot of hopes on this.

Comments (11)