Beats 99.44% runtime | Python3 | Sets
Approach\nWe need to find the "end destination", ie the place from where you can go any further. In the test cases, you can notice that the "end destination" is
# Approach\nWe need to find the "end destination", ie the place from where you can go any further. In the test cases, you can notice that the "end destination" is never a start (by "start" I mean the first elem of a sublist. By "destination", I mean the second elem of a sublist)\n\nSo I just find the place which is never a start. I do that by first storing all the starts in a set called "starts" (since sets have a O(1) lookup, as opposed to the O(n) lookup in lists), and then loop through every destination and check which destinaion never appears as a start\n\n# Complexity\n- Time complexity: O(2n)\n\n\n# Code\n```python3\nclass Solution:\n    def destCity(self, paths: List[List[str]]) -> str:\n        starts = {i[0] for i in paths}\n\n        for i in paths:\n            if i[1] not in starts:\n                starts.clear()\n                paths.clear()\n                return i[1]\n```
['Python3']