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

Function dest_city

1436-destination-city.rs:10–26  ·  view source on GitHub ↗
(paths: Vec<Vec<String>>)

Source from the content-addressed store, hash-verified

8}
9
10pub fn dest_city(paths: Vec<Vec<String>>) -> String {
11 let mut res = vec!();
12 for path in paths {
13 for (i, des) in path.into_iter().enumerate() {
14 if res.contains(&des) {
15 res.retain(|value| *value != des);
16 } else {
17 if i == 0 {
18 res.insert(0, des);
19 } else {
20 res.push(des);
21 }
22 }
23 }
24 }
25 res[1].to_string()
26}

Callers

nothing calls this directly

Calls 3

containsMethod · 0.80
insertMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected