QuestionYou are given anm x ngridgridof values0,1, or2, where:each0marksan empty landthat you can pass by freely,each1marksa buildingthat you cannot pass through, andeach2marksan obstaclethat you cannot pass through.You want to build a house on an empty land that reaches all buildings in theshortest total traveldistance. You can only move up, down, left, and right.Returntheshortest travel distancefor such a house. If it is not possible to build such a house according to the above rules, return-1.Thetotal travel distanceis the sum of the distances between the houses of the friends and the meeti
...
继续阅读
(74)