题目描述:
示例 1:
示例 2:
示例 3:
示例 4:
示例 5:
思路:
代码实现:
class Solution {
public boolean escapeGhosts(int[][] ghosts, int[] target) {
int mark = result(0, 0, target[0], target[1]);
for (int[] arr : ghosts) {
if (result(arr[0], arr[1], target[0], target[1]) <= mark) return false;
}
return true;
}
public int result(int x1, int y1, int x2, int y2) {
return Math.abs(x1 - x2) + Math.abs(y1 - y2);
}
}