[C++] Can PAC-MAN reach the target first? O(n) runtime
The PAC-MAN can escape the ghosts iff minimum moves required by PAC-MAN to reach the target is less than the minimum moves required by any ghost to reach the ta
The PAC-MAN can escape the ghosts ***iff*** minimum moves required by PAC-MAN to reach the target is less than the minimum moves required by any ghost to reach the target.\n\n```\nclass Solution {\npublic:\n    bool escapeGhosts(vector<vector<int>>& ghosts, vector<int>& target) {\n        int pacman = abs(target[0]) + abs(target[1]);\n        for (const auto& ghost: ghosts) {\n            if (abs(target[0] - ghost[0]) + abs(target[1] - ghost[1]) <= pacman) return false;\n        }\n        return true;\n    }\n};\n```
[]