Escape The Ghosts LeetCode solution in C++

1
class Solution {
2
public:
3
bool escapeGhosts(vector<vector<int>> &ghosts, vector<int> &target) {
4
int minimumstepsreqbyplayer = abs(target[0]) + abs(target[1]);
5
int minimumstepsreqbyanyghost = INT_MAX;
6

7
for (auto x : ghosts) {
8
minimumstepsreqbyanyghost =
9
min(minimumstepsreqbyanyghost, abs(x[0] - target[0]) + abs(x[1] - target[1]));
10
}
11

12
return minimumstepsreqbyplayer < minimumstepsreqbyanyghost;
13
}
14
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0