/*
// Employee info
class Employee {
public:
// It's the unique ID of each node.
// unique id of this employee
int id;
// the importance value of this employee
int importance;
// the id of direct subordinates
vector<int> subordinates;
};
*/
class Solution {
public:
int all=0;//全局变量;
int getImportance(vector<Employee*> employees, int id) {
int len=employees.size();
int aim;
//找出给定ID所在位置;
for(int i=0;i!=len;i++)
{
if(employees[i]->id==id)
{
all +=employees[i]->importance;
aim=i;
break;
}
}
//
现在输入一个公司的所有员工信息,以及单个员工id,返回这个员工和他所有下属的重要度之和。
最新推荐文章于 2022-05-14 22:49:55 发布