Destination City LeetCode solution in Java

1
class Solution {
2
public String destCity(List<List<String>> paths) {
3
HashSet<String> set1 = new HashSet<>();
4

5
for (int i = 0; i < paths.size(); ++i) {
6
set1.add(paths.get(i).get(0));
7
}
8
for (int i = 0; i < paths.size(); ++i) {
9
if (!set1.contains(paths.get(i).get(1))) return paths.get(i).get(1);
10
}
11
return "placeholder";
12
}
13
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0