Leetcode 1547 Solution

This article provides solution to leetcode question 1547 (destination-city)

https://leetcode.com/problems/destination-city

Solution

class Solution:
    def destCity(self, paths: List[List[str]]) -> str:
        in_nodes = set()
        out_nodes = set()
        for src, dst in paths:
            out_nodes.add(src)
            in_nodes.add(dst)
        return list(in_nodes - out_nodes)[0]