哈希表存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. C++-codeblocks安装

    2020-02-15 "Test_leetcode - Debug": The compiler's setup (GNU GCC Compiler) is invalid, so ...

  2. 微信小程序 下拉刷新

    <scroll-view class='scroll-view-container' scroll-y="true" bindscrolltolower='scrollToL ...

  3. cookie 与session

    Django 操作cookie,session HTTP协议四大特性: 1.基于TCP.IP作用与应用层的协议 2.基于请求响应 3.无连接 4.无状态 无状态的意思是每次请求都是独立的,它的执行情况 ...

  4. python 子进程

    1.线程的介绍(理论部分) 1.1 进程线程分工 我们之前讲运行一个py文件,就是开启了一个进程,在内存中开辟一个进程空间,将必要的数据加载到这个进程空间,然后cpu在去调用这个进程的主线程去执行具体 ...

  5. 17.java设计模式之观察者模式

    基本需求: 气象站可以将每天测量到的温度,湿度,气压等等,以公告的形式发布出去(比如发布到自己的网站或第三方) 需要设计开放型API,便于其他第三方也能接入气象站获取数据 提供温度.气压和湿度的接口 ...

  6. day1(初始化项目结构)

    1.初始化项目结构  └─shiyanlou_project    │  .gitignore    │  README.en.md           # 英文    │  README.md    ...

  7. 第11.12节 Python元字符“|”支持的正则表达式多选一匹配模式

    re模块支持多个正则表达式使用"|"(逻辑或)模式来组合,扫描目标字符串时, '|' 分隔开的正则表达式组合从左到右进行匹配,只要其中一个匹配成功就认为该组合匹配成功,不再进行组合 ...

  8. Python学习随笔:PyCharm的错误检测使用及调整配置减少错误数量

    老猿使用PyCharm有将近一个月了,发现PyCharm并不能很好的完成语法检查,有时运行时突然终止,仔细核查却发现是基本的语法错误,不过有次无意中移动鼠标到代码最右边的边框时发现其实PyCharm有 ...

  9. PyQt(Python+Qt)学习随笔:窗口对象尺寸调整相关的函数resize、showMaximized、showNormal、showMinimized

    resize(width,height) resize可以直接调整窗口的尺寸,调整效果类似于鼠标直接拉伸或缩小窗口,但窗口大小的最大值.最小值受窗口的sizePolicy.sizeHint.minim ...

  10. 代码审计【根据功能点定向审计】BugFree ZSWin重装案例

    (哦对了!这些CMS代码不要安装在服务器上,先不说它们用来代码审计本身就是有漏洞的,而且在网上下载下来,也不能保证没有源码是否被篡改而留有后门,就安装在本地进行代码审计的练习即可) 我们先下载BugF ...