aboutsummaryrefslogtreecommitdiffstats
path: root/1436
diff options
context:
space:
mode:
Diffstat (limited to '1436')
-rwxr-xr-x1436/main.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/1436/main.py b/1436/main.py
new file mode 100755
index 0000000..16291ce
--- /dev/null
+++ b/1436/main.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+import typing
+
+
+class Solution:
+ def destCity(self, paths: typing.List[typing.List[str]]) -> str:
+ one = {}
+ for path in paths:
+ one[path[0]] = path[1]
+
+ dest = one[paths[0][0]]
+ while dest in one:
+ dest = one[dest]
+
+ return dest
+
+
+def main():
+ solution = Solution()
+ paths = [["London", "New York"], ["New York", "Lima"], ["Lima", "Sao Paulo"]]
+ print(solution.destCity(paths))
+
+
+if __name__ == "__main__":
+ main()