Skip to content

Commit 09cbb32

Browse files
authored
Create 1436-destination-city.kt
1 parent 577c1b2 commit 09cbb32

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

kotlin/1436-destination-city.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
fun destCity(paths: List<List<String>>): String {
3+
var fromCity: HashSet<String> = hashSetOf()
4+
for (path in paths)
5+
fromCity.add(path[0])
6+
7+
var res = paths[0][1]
8+
for (path in paths) {
9+
if (path[1] !in fromCity) {
10+
res = path[1]
11+
break
12+
}
13+
}
14+
15+
return res
16+
}
17+
}

0 commit comments

Comments
 (0)