Escape The Ghosts LeetCode solution in Java

1
// Escape The Ghosts
2
// Leetcode: https://leetcode.com/problems/escape-the-ghosts/
3

4
class Solution {
5
public boolean escapeGhosts(int[][] ghosts, int[] target) {
6
int dist = Math.abs(target[0]) + Math.abs(target[1]);
7
for (int[] ghost : ghosts) {
8
if (Math.abs(ghost[0] - target[0]) + Math.abs(ghost[1] - target[1]) <= dist) {
9
return false;
10
}
11
}
12
return true;
13
}
14
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0