哈希表存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. springmvc跨域问题

    1.跨域问题: 按照网上所有的方法试了一遍,都没跨过去,正在无助之际,使用filter按照下面的方法解决的时候出现了转机: 添加filter: package com.thc.bpm.filter; ...

  2. moviepy音视频剪辑:使用fl_time报错OSError: MoviePy error: failed to read the first frame of video file

    专栏:Python基础教程目录 专栏:使用PyQt开发图形界面Python应用 专栏:PyQt+moviepy音视频剪辑实战 专栏:PyQt入门学习 老猿Python博文目录 老猿学5G博文目录 在m ...

  3. Python函数学习遇到的问题

    Python函数的关键字参数 Python函数独立星号(*)分隔的命名关键字参数 Python函数中的位置参数 Python中对输入的可迭代对象元素排序的sorted函数 Python中函数的参数带星 ...

  4. PyQt(Python+Qt)学习随笔:QTreeView树形视图的indentation属性

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 QTreeView树形视图的indentation属性用于控制视图中每级数据项之间的缩进,对于顶级项 ...

  5. CTF流量分析题大全(掘安攻防平台)

    突然想做一下流量分析题,记得掘安攻防实验室上面有很多的流量分析题目,故做之 流量分析题一般使用的都是wireshark,(流量分析工具中的王牌 夺取阿富汗 说了分析http头,所以直接过滤http协议 ...

  6. flask实现分类搜索的小测试

    最新学长要求实现一个搜索的功能呢,也费了一点功夫.这个案例也没有学长写的好,比学长的实现差了不少,待我仔细研究习再发出相应代码 项目要求,搜索语法如下: titile: xxx #搜索titile的所 ...

  7. 冲刺Day6

    每天举行站立式会议照片: 昨天已完成的工作: 1.确认商品搜索栏页面(全) 2.订单模块的大部分代码 3.用户模块的大部分代码 今天计划完成的工作: 成员 任务 高嘉淳 检查用户模块的功能并更正 覃泽 ...

  8. shell--检查apache是否启动脚本

    #首先我们需要检查apache是否以启动,这里我们用到的说nmap命令,Linux默认情况下是没有安装nmap命令的. #那么我们需要安装下nmap,安装的命令很简单:yum -y install n ...

  9. Flask开发技巧之参数校验

    Flask开发技巧之参数校验 目录 Flask开发技巧之参数校验 1.请求参数分类 2.解决方案使用到的库 3.针对url查询参数与一般json格式 4.针对复杂json格式数据 本人平时开发中使用的 ...

  10. ES6、ES7、ES8

    ES6 https://es6.ruanyifeng.com/   ES7 1.Array.prototype.includes() includes()作用,是查找一个值在不在数组里,若是存在则返回 ...