Facebook phone screen - Shortest Distance from All Houses

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 =


嗯, https://leetcode.com/problems/shortest-distance-from-all-buildings/ 参考