1436. Destination City
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 01, 2024
Last updated : July 01, 2024
Related Topics : Array, Hash Table, String
Acceptance Rate : 79.48 %
class Solution {
public String destCity(List<List<String>> paths) {
HashSet<String> srcs = new HashSet<>();
for (int i = 0; i < paths.size(); i++) {
srcs.add(paths.get(i).get(0));
}
for (int i = 0; i < paths.size(); i++) {
if (!srcs.contains(paths.get(i).get(1))) {
return paths.get(i).get(1);
}
}
return null;
}
}