From 76c9f3584cd5dd882f7d77ef16e3fba52407d0f0 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Fri, 15 Dec 2023 11:58:52 -0500 Subject: 1436 --- 1436/main.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 1436/main.py 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() -- cgit v1.2.3