Skip to content

Commit 8efaeaa

Browse files
authored
Create destination-city.py
1 parent ae8e93e commit 8efaeaa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Python/destination-city.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
import itertools
5+
6+
7+
class Solution(object):
8+
def destCity(self, paths):
9+
"""
10+
:type paths: List[List[str]]
11+
:rtype: str
12+
"""
13+
A, B = map(set, itertools.izip(*paths))
14+
return (B-A).pop()

0 commit comments

Comments
 (0)