1436. Destination City Easy

@problem@discussion
#Hash Table#String



1/**
2 * [1436] Destination City
3 *
4 * You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.
5 * It is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city.
6 *  
7 * Example 1:
8 * 
9 * Input: paths = [["London","New York"],["New York","Lima"],["Lima","Sao Paulo"]]
10 * Output: "Sao Paulo" 
11 * Explanation: Starting at "London" city you will reach "Sao Paulo" city which is the destination city. Your trip consist of: "London" -> "New York" -> "Lima" -> "Sao Paulo".
12 * 
13 * Example 2:
14 * 
15 * Input: paths = [["B","C"],["D","B"],["C","A"]]
16 * Output: "A"
17 * Explanation: All possible trips are: 
18 * "D" -> "B" -> "C" -> "A". 
19 * "B" -> "C" -> "A". 
20 * "C" -> "A". 
21 * "A". 
22 * Clearly the destination city is "A".
23 * 
24 * Example 3:
25 * 
26 * Input: paths = [["A","Z"]]
27 * Output: "Z"
28 * 
29 *  
30 * Constraints:
31 * 
32 * 	1 <= paths.length <= 100
33 * 	paths[i].length == 2
34 * 	1 <= cityAi.length, cityBi.length <= 10
35 * 	cityAi != cityBi
36 * 	All strings consist of lowercase and uppercase English letters and the space character.
37 * 
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/destination-city/
42// discuss: https://leetcode.com/problems/destination-city/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47    pub fn dest_city(paths: Vec<Vec<String>>) -> String {
48        String::new()
49    }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56    use super::*;
57
58    #[test]
59    fn test_1436() {
60    }
61}
62


Back
© 2025 bowen.ge All Rights Reserved.