Screening Round
Questions: Given two inputs,
First input is the location map, a 2D array
| O | E | E | E | X | |---|---|---|---|---| | E | O | X | X | X | | E | E | E | E | E | | X | E | O | E | E | | X | E | X | E | X |
O = Robot, E = Empty, X = blocker
Second input is the query. It’s a 1D array consisting of distance to the closest blocker in the order from **left, **top, *bottom and right
[2, 2, 4, 1]
This means distance of 2 to the left blocker, 2 to the top blocker, 4 to the bottom blocker and 1 to the right blocker.
Note: The location map boundary is also considered a blocker, meaning if the robot hits the boundary it also means it’s hitting the blocker.
Return the coordinates of all robots who can satisfy the move given by the second input.
Is there any Leetcode equivalent of this problem?
Candidate's Approach
I proposed a solution which goes linearly through the location map. For each robot detected, we would do a boundary check and return the result. The time complexity of such a solution would be O(mnmax(secondInputValues)).
Interviewer's Feedback
No feedback provided.