Amazon | SDE2 | Phone Screen | Vancouver
Anonymous User
1001

Interviewer was 15 minutes late. Basically headed straight into the coding question. Initially asked me if i understood the problem, and we talked through it, and i came up with a brute force apporach (no code, just writing comments on the ide). Interviewer told me to think of a more optimal solution right away, before I even had a chance to code anything, and eventually suggested I use a stack.

Had about 20 minutes to code a solution, and came up with answer that was 80% complete.
Overall I wasn't impressed with how I did. I am a bit upset that the interviewer didnt give me a chance to code the brute force solution, because generally speaking I have an easier time creating a workable solution first, then itterating and making it efficient. I find it difficult to come up with a perfectly efficient algo the very first time. Will update this post If I move onto the second round, but i am very doubtful.

In a two dimensional area (P*Q), there is house at every coordinate.Houses are present at all points (i, j) where i lies between [1, P] and j lies between 
[1,Q]. Due to some power circuit, some random x number of houses caught fire. After every 1 minute, house which are at 1 unit distance from 
burning house catch fire. Find the house which start burning at the last and how much time it will take for fire to reach to last house. 
If there are multiple houses, print coordinates of any. Houses are present at all points (i,j) where i lies between [1, P] and j lies between [1,Q]. 

*Input* The first input line contains two integers 
P, Q (1 ≤ P ,Q≤ 2000) — the size of the area. *The houses were present in all points of the (**x, y) (1 ≤ x ≤ N, 1 ≤ y ≤ M) type, x and 
y are integers.* The second line contains an integer K (1 ≤ K ≤ 10) — number of houses, burning in the beginning. 
The third line contains K pairs of integers: x1, y1, x2, y2, ..., xk, yk (1 ≤ xi ≤ Q, 1 ≤ yi ≤ P) — coordinates of the points from which the fire started. 
It is guaranteed that no two points coincide. 

Output: Output a line with three space-separated integers x, y and t where x and y are coordinates of the house
that will be the last one to start burning and t is time taken to reach 
that house. If there are several such house, output any. (1,1) (1,2) (1,3) (2,1) () */
Comments (2)