aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2023-12-15 16:58:52 +0000
committerterminaldweller <devi@terminaldweller.com>2023-12-15 16:58:52 +0000
commit76c9f3584cd5dd882f7d77ef16e3fba52407d0f0 (patch)
tree99e3c73d555daf44080e6398e786ecc6f85538f2
parent606 (diff)
downloadleetcode-76c9f3584cd5dd882f7d77ef16e3fba52407d0f0.tar.gz
leetcode-76c9f3584cd5dd882f7d77ef16e3fba52407d0f0.zip
1436
Diffstat (limited to '')
-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()