# 690. 员工的重要性

<https://leetcode-cn.com/problems/employee-importance/>

## 解法一：

以id为key，Employee结构为value写入map中，为了找出所有嵌套下属员工，用递归。

```python
"""
# Employee info
class Employee:
    def __init__(self, id, importance, subordinates):
        # It's the unique id of each node.
        # unique id of this employee
        self.id = id
        # the importance value of this employee
        self.importance = importance
        # the id of direct subordinates
        self.subordinates = subordinates
"""
class Solution:
    def getImportance(self, employees, id):
        """
        :type employees: Employee
        :type id: int
        :rtype: int
        """
        self.eMap = {}
        for e in employees:    #存入map
            self.eMap[e.id] = e
        return self.helper(id)
    
    def helper(self, id):
        imp = self.eMap[id].importance    #当前员工
        #递归访问下属员工
        for s in self.eMap[id].subordinates:
            imp += self.helper(s)
        return imp
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cai-sen-se.gitbook.io/leetcode/601-800/690.-yuan-gong-de-zhong-yao-xing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
