Facebook | Phone screen | Shortest Distance from All Houses

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2019-05-30Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: e3, e4
Interview Stage: Phone screen
Location: unknown
Year: unknown

Original Post Content:

You’ve been tasked to help a village find the best place to install a new well. You’re given a 2D grid where cells can be empty, a house, or a tree. People can walk up, down, left and right, but they can’t walk through trees. Place the well that minimizes the total sum distance from all the houses.

=. =. =. =
= H T =
= H T =
= = H =

Comments