算法分析与设计第十三周:582. Kill Process

来源:互联网 发布:sqlserver update多行 编辑:程序博客网 时间:2024/06/11 15:51
class Solution(object):    def killProcess(self, pid, ppid, kill):        dict1 = {}        size = len(pid)        res = [kill]        for i in range(size):            if dict1.get(ppid[i]) == None:                dict1[ppid[i]] = [pid[i]]            else:                dict1[ppid[i]] += [pid[i]]        kill = [kill]        while kill != []:            tmp = kill[0]            if dict1.get(tmp) != None:                res += dict1[tmp]                kill += dict1[tmp]            del kill[0]        return res

这里写图片描述

原创粉丝点击