这题考阅读理解和题意转化能力,其实问的就是有没鬼能比你更快到达终点(转)
(ghosts: Vec<Vec<i32>>, target: Vec<i32>)
| 1 | // 这题考阅读理解和题意转化能力,其实问的就是有没鬼能比你更快到达终点(转) |
| 2 | pub fn escape_ghosts(ghosts: Vec<Vec<i32>>, target: Vec<i32>) -> bool { |
| 3 | let dis = target[0].abs() + target[1].abs(); |
| 4 | for g in ghosts { |
| 5 | if (g[0] - target[0]).abs() + (g[1] - target[1]).abs() <= dis { |
| 6 | return false |
| 7 | } |
| 8 | } |
| 9 | true |
| 10 | } |
| 11 | |
| 12 | fn main() { |
| 13 | println!("{:?}", escape_ghosts(vec![vec![1,0], vec![0,3]], vec![0,1])); |
nothing calls this directly
no outgoing calls
no test coverage detected