[Rust] 3 lines, 0ms with explanation
\nThe idea is simple: two sets s, t to cache source cities and destinations cities, then the difference of the two sets is the set of final-destinations cities.
\nThe idea is simple: two sets `s, t` to cache source cities and destinations cities, then the difference of the two sets is the set of final-destinations cities.\n\n### Rust Code\n```rust\nimpl Solution {\n    pub fn dest_city(paths: Vec<Vec<String>>) -> String {\n        let s: HashSet<String> = paths.iter().map(|v| v[0].clone()).collect();\n        let t: HashSet<String> = paths.iter().map(|v| v[1].clone()).collect();\n        t.difference(&s).collect::<Vec<&String>>()[0].to_string()\n    }\n}\n```\n\nIf you like this post, please vote up, it would be really encouraging. \nAnd if you have any thoughts, please leave a comment. \n
[]