Destination City LeetCode solution in Python

1
# Runtime: 101 ms (Top 25.06%) | Memory: 13.8 MB (Top 81.64%)
2
from collections import defaultdict
3

4

5
class Solution:
6
def destCity(self, paths: List[List[str]]) -> str:
7
deg = defaultdict(int)
8
for v, w in paths:
9
deg[v] += 1
10
deg[w]
11
for v in deg:
12
if not deg[v]:
13
return v

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0