Escape The Ghosts LeetCode solution in Java
1// Escape The Ghosts2// Leetcode: https://leetcode.com/problems/escape-the-ghosts/34class Solution {5public boolean escapeGhosts(int[][] ghosts, int[] target) {6int dist = Math.abs(target[0]) + Math.abs(target[1]);7for (int[] ghost : ghosts) {8if (Math.abs(ghost[0] - target[0]) + Math.abs(ghost[1] - target[1]) <= dist) {9return false;10}11}12return true;13}14}