哈希表存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. day3(Vue组件)

    1.组件定义 1.定义组件并引用 2.父组件向子组件传值 3.子组件向父组件传值 # 组件间传值:vuex (https://www.cnblogs.com/xiaonq/p/9697921.html ...

  2. Java虚拟机之内存区域

    原创文章,转载请标明出处! 目录 一.背景 二.运行时内存区域概述 1.官方描述 2.中文翻译 3.内存区域简述 4.运行时数据区简图 5.运行时数据区详图 三.JVM线程 JVM数据区域与线程关系 ...

  3. PyQt(Python+Qt)学习随笔:QSpinBox数字设定部件简介

    专栏:Python基础教程目录 专栏:使用PyQt开发图形界面Python应用 专栏:PyQt入门学习 老猿Python博文目录 老猿学5G博文目录 在输入部件中,数字调整框QSpinBox是个很实用 ...

  4. 老猿学5G扫盲贴:移动边缘计算(Mobile Edge Computing, MEC)

    版权声明:本文为CSDN博主「魏晓蕾」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明. 原文链接:https://blog.csdn.net/gongxifaca ...

  5. 第11.14节 正则表达式转义符和Python转义符相同引发问题的解决办法

    正则表达式使用反斜杠('\')来把特殊字符转义成普通字符(为了方便称为"正则表达式转义"),而反斜杠在普通的 Python 字符串里也是转义符(称为"字符串转义" ...

  6. [BJDCTF 2nd]duangShell

    [BJDCTF 2nd]duangShell 点击进去之后提示我们swp源代码泄露,访问http://xxx/.index.php.swp下载该文件 该文件产生的原因是:​使用vi编辑器打开文件时,会 ...

  7. upload 注意php远程安全模式屏蔽函数

    进来:上传一个一句话php,果然不行:改成jpg后缀,上传成功:接着写一个.htaccess文件去把.jpg解析成.php,如下: AddType application/x-httpd-php .j ...

  8. Docker下Python Flask+Redis+MySQL+RQ队列简单配置

    本篇博文主要讲解Docker下使用RQ队列的通信配置,主要是网上的部分文章写的不太清楚,特写一篇 作者使用docker-compose.yml文件调度各部分文件Dockerfile,起初是这样写的 v ...

  9. PHP代码审计分段讲解(3)

    05 ereg正则%00截断 放上源代码 <?php $flag = "flag"; if (isset ($_GET['password'])) { if (ereg (& ...

  10. xlwt:python的写excel模块

    最近工作时碰到了将数据导出,生成一个excel表,对其中的部分数据进行统计,并给其中部分符合条件的数据添加对应的背景颜色的功能需求,于是乎,对Python中写excel的模块xlwt研究了一下,在工作 ...