- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1436.java
26 lines (24 loc) · 762 Bytes
/
_1436.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
packagecom.fishercoder.solutions.secondthousand;
importjava.util.HashSet;
importjava.util.List;
importjava.util.Set;
publicclass_1436 {
publicstaticclassSolution1 {
publicStringdestCity(List<List<String>> paths) {
Set<String> sourceSet = newHashSet<>();
Set<String> destSet = newHashSet<>();
for (List<String> path : paths) {
Stringsource = path.get(0);
Stringdest = path.get(1);
sourceSet.add(source);
destSet.add(dest);
}
for (Stringdest : destSet) {
if (!sourceSet.contains(dest)) {
returndest;
}
}
return"";
}
}
}