MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / escape_ghosts

Function escape_ghosts

789-escape-the-ghosts.rs:2–10  ·  view source on GitHub ↗

这题考阅读理解和题意转化能力,其实问的就是有没鬼能比你更快到达终点(转)

(ghosts: Vec<Vec<i32>>, target: Vec<i32>)

Source from the content-addressed store, hash-verified

1// 这题考阅读理解和题意转化能力,其实问的就是有没鬼能比你更快到达终点(转)
2pub 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
12fn main() {
13 println!("{:?}", escape_ghosts(vec![vec![1,0], vec![0,3]], vec![0,1]));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected