哈希表存id和员工数据结构

递归获取信息

public int getImportance(List<Employee> employees, int id) {
Map<Integer,Employee> map = new HashMap<>();
for (int i = 0; i < employees.size(); i++) {
Employee temp = employees.get(i);
map.put(temp.id,temp);
}
return helper(map,id);
}
public int helper(Map<Integer,Employee> map, int id)
{
Employee cur = map.get(id);
List<Integer> sub = cur.subordinates;
int res = cur.importance;
for (int i = 0; i < sub.size(); i++) {
res += helper(map,sub.get(i));
}
return res;
}

[LeetCode]690. Employee Importance员工重要信息的更多相关文章

  1. (BFS) leetcode 690. Employee Importance

    690. Employee Importance Easy 377369FavoriteShare You are given a data structure of employee informa ...

  2. LN : leetcode 690 Employee Importance

    lc 690 Employee Importance 690 Employee Importance You are given a data structure of employee inform ...

  3. LeetCode 690. Employee Importance (职员的重要值)

    You are given a data structure of employee information, which includes the employee's unique id, his ...

  4. LeetCode - 690. Employee Importance

    You are given a data structure of employee information, which includes the employee's unique id, his ...

  5. LeetCode 690 Employee Importance 解题报告

    题目要求 You are given a data structure of employee information, which includes the employee's unique id ...

  6. 690. Employee Importance员工权限重要性

    [抄题]: You are given a data structure of employee information, which includes the employee's unique i ...

  7. leetcode 690. Employee Importance——本质上就是tree的DFS和BFS

    You are given a data structure of employee information, which includes the employee's unique id, his ...

  8. 690. Employee Importance - LeetCode

    Question 690. Employee Importance Example 1: Input: [[1, 5, [2, 3]], [2, 3, []], [3, 3, []]], 1 Outp ...

  9. 【Leetcode_easy】690. Employee Importance

    problem 690. Employee Importance 题意:所有下属和自己的重要度之和,所有下属包括下属的下属即直接下属和间接下属. solution:DFS; /* // Employe ...

随机推荐

  1. uni搜索功能实现

    uni搜索功能的实现

  2. LeetCode 038 Count and Say

    题目要求:Count and Say The count-and-say sequence is the sequence of integers beginning as follows:1, 11 ...

  3. 使用 IDEA 创建多模块项目

    网上找如何创建多模块项目的资料,大多类似,实践中又各有问题,此文为摸索之后总结 最终项目结构如下: 项目引用关系:app → service → dao 新建父项目 multi-parent mult ...

  4. 20200427_ls_正在读取目录_输入/输出错误

    环境: 在Centos7.2上挂载了一个2T的移动硬盘, 使用vim 在移动硬盘中编辑 .sh文件, wq的时候提示出错, 然后清空的文件, 可以正常wq出来 [root@localhost yido ...

  5. 第十三章、Designer中的按钮Buttons组件详解

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 一.引言 Qt Designer中的Buttons部件包括Push Button(常规按钮.一般称按 ...

  6. 【软件测试部署基础】gradle的认识

    1. gradle简介 Java世界中主要有三大构建工具:Ant.Maven和Gradle.经过几年的发展,Ant几乎销声匿迹.Maven也日薄西山,而Gradle的发展则如日中天. 1.1. ANT ...

  7. 深入理解Java虚拟机(三)——垃圾回收策略

    所谓垃圾收集器的作用就是回收内存空间中不需要了的内容,需要解决的问题是回收哪些数据,什么时候回收,怎么回收. Java虚拟机的内存分为五个部分:程序计数器.虚拟机栈.本地方法栈.堆和方法区. 其中程序 ...

  8. STL——容器(List)list 的反序排列

    list.reverse(); //反转链表,比如list包含1, 2, 3, 4, 5五个元素,运行此方法后,list就包含5, 4, 3, 2, 1元素. 1 #include <iostr ...

  9. sqli-labs less13-20(各种post型头部注入)

    less-13 POST型双查询注入 less-14 POST型双查询注入 less-15 POST型布尔注入 less-16 POST型布尔注入 less-17 POST型报错注入(updatexm ...

  10. mysql-zerofill关键字

    zerofill位数填充 mysql> create table shop( -> article int(4) unsigned zerofill default '0000' not ...