Skip to content

Commit 577c1b2

Browse files
Create 1436-destination-city.java
1 parent 0f3b334 commit 577c1b2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

java/1436-destination-city.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public String destCity(List<List<String>> paths) {
3+
Set<String> set = new HashSet<>();
4+
for(List<String> path: paths){
5+
String city = path.get(0);
6+
set.add(city);
7+
}
8+
9+
for(List<String> path: paths){
10+
String city = path.get(1);
11+
if(!set.contains(city))
12+
return city;
13+
}
14+
return "";
15+
}
16+
}

0 commit comments

Comments
 (0)