690. Employee Importance
程序员文章站
2022-03-03 11:21:06
...
/*
// 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;
};
*/
void employeevalue(vector<Employee*> employees, int id, int &val)
{
Employee *empTemp;
for(auto au : employees)
{
if(au->id == id)
{
empTemp = au;
}
}
val = val + empTemp->importance;
for(int n = 0; n < empTemp->subordinates.size(); n++)
{
employeevalue(employees, empTemp->subordinates[n], val);
}
}
class Solution {
public:
int getImportance(vector<Employee*> employees, int id) {
int nval = 0;
employeevalue(employees, id, nval);
return nval;
}
};
上一篇: Canvas学习记录绘制七巧板(01)
下一篇: canvas学习(一):七巧板
推荐阅读
-
jmu-Java-03面向对象-06-继承覆盖综合练习-Person、Student、Employee、Company (20 分) ///答案,不包括解析
-
Deep feature importance awareness based no-reference image quality prediction
-
创建一个TreeSet对象,并在其中添加一些员工对象(Employee),其姓名和工资分别是:张三8000,李四6000,王五5600,马六7500.最后按照工资的大小,降序输出(提示:让Employ
-
690-Employee Importance
-
【Leetcode】690. 员工的重要性
-
Java/690.Employee Importance 员工的重要性
-
Deep feature importance awareness based no-reference image quality prediction
-
jmu-Java-03面向对象-06-继承覆盖综合练习-Person、Student、Employee、Company (20 分) ///答案,不包括解析
-
matplotlib中的plot_importance画图大小控制
-
创建一个TreeSet对象,并在其中添加一些员工对象(Employee),其姓名和工资分别是:张三8000,李四6000,王五5600,马六7500.最后按照工资的大小,降序输出(提示:让Employ