Python short & fast solution beats 100%

  • 0
    class Solution(object):
        def killProcess(self, pid, ppid, kill):
            :type pid: List[int]
            :type ppid: List[int]
            :type kill: int
            :rtype: List[int]
            child = collections.defaultdict(list)
            ret = []
            for c, p in zip(pid, ppid):
            stack = [kill]
            while stack:
                current = stack.pop()
                stack += child[current]
            return ret

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.