problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::kill_process::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static vector< int > killProcess (vector< int > &pid, vector< int > &ppid, int kill)
 

详细描述

在文件 leetcode.h2886 行定义.

成员函数说明

◆ killProcess()

vector< int > leetcode::kill_process::Solution::killProcess ( vector< int > &  pid,
vector< int > &  ppid,
int  kill 
)
static

在文件 leetcode.cpp7984 行定义.

7984 {
7985 unordered_map<int, Node *> um;
7986 for(const auto &v: pid) {
7987 um[v] = new Node(v);
7988 }
7989 for(int i = 0; i < pid.size(); i++) {
7990 if(ppid[i] != 0) {
7991 um[ppid[i]]->children.insert(um[pid[i]]);
7992 }
7993 }
7994 vector<int> ans;
7995 queue<Node *> q;
7996 q.push(um[kill]);
7997 while(!q.empty()) {
7998 Node *node = q.front();
7999 q.pop();
8000 ans.emplace_back(node->val);
8001 for(auto *next: node->children) {
8002 q.push(next);
8003 }
8004 }
8005 return ans;
8006 }

引用了 leetcode::kill_process::Node::children , 以及 leetcode::kill_process::Node::val.

被这些函数引用 leetcode::kill_process::TEST().


该类的文档由以下文件生成: