Employee Importance
<p>You have a data structure of employee information, including the employee&#39;s unique ID, importance value, and direct subordinates&#39; IDs.</p>

<p>You are given an array of employees <code>employees</code> where:</p>

<ul>
	<li><code>employees[i].id</code> is the ID of the <code>i<sup>th</sup></code> employee.</li>
	<li><code>employees[i].importance</code> is the importance value of the <code>i<sup>th</sup></code> employee.</li>
	<li><code>employees[i].subordinates</code> is a list of the IDs of the direct subordinates of the <code>i<sup>th</sup></code> employee.</li>
</ul>

<p>Given an integer <code>id</code> that represents an employee&#39;s ID, return <em>the <strong>total</strong> importance value of this employee and all their direct and indirect subordinates</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/05/31/emp1-tree.jpg" style="width: 400px; height: 258px;" />
<pre>
<strong>Input:</strong> employees = [[1,5,[2,3]],[2,3,[]],[3,3,[]]], id = 1
<strong>Output:</strong> 11
<strong>Explanation:</strong> Employee 1 has an importance value of 5 and has two direct subordinates: employee 2 and employee 3.
They both have an importance value of 3.
Thus, the total importance value of employee 1 is 5 + 3 + 3 = 11.
</pre>

<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/05/31/emp2-tree.jpg" style="width: 362px; height: 361px;" />
<pre>
<strong>Input:</strong> employees = [[1,2,[5]],[5,-3,[]]], id = 5
<strong>Output:</strong> -3
<strong>Explanation:</strong> Employee 5 has an importance value of -3 and has no direct subordinates.
Thus, the total importance value of employee 5 is -3.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= employees.length &lt;= 2000</code></li>
	<li><code>1 &lt;= employees[i].id &lt;= 2000</code></li>
	<li>All <code>employees[i].id</code> are <strong>unique</strong>.</li>
	<li><code>-100 &lt;= employees[i].importance &lt;= 100</code></li>
	<li>One employee has at most one direct leader and may have several subordinates.</li>
	<li>The IDs in <code>employees[i].subordinates</code> are valid IDs.</li>
</ul>

['nested-list-weight-sum']
[]
[{"value": "cpp", "text": "C++", "defaultCode": "/*\n// Definition for Employee.\nclass Employee {\npublic:\n    int id;\n    int importance;\n    vector<int> subordinates;\n};\n*/\n\nclass Solution {\npublic:\n    int getImportance(vector<Employee*> employees, int id) {\n        \n    }\n};"}, {"value": "java", "text": "Java", "defaultCode": "/*\n// Definition for Employee.\nclass Employee {\n    public int id;\n    public int importance;\n    public List<Integer> subordinates;\n};\n*/\n\nclass Solution {\n    public int getImportance(List<Employee> employees, int id) {\n        \n    }\n}"}, {"value": "python", "text": "Python", "defaultCode": "\"\"\"\n# Definition for Employee.\nclass Employee(object):\n    def __init__(self, id, importance, subordinates):\n    \t#################\n        :type id: int\n        :type importance: int\n        :type subordinates: List[int]\n        #################\n        self.id = id\n        self.importance = importance\n        self.subordinates = subordinates\n\"\"\"\n\nclass Solution(object):\n    def getImportance(self, employees, id):\n        \"\"\"\n        :type employees: List[Employee]\n        :type id: int\n        :rtype: int\n        \"\"\"\n        "}, {"value": "python3", "text": "Python3", "defaultCode": "\"\"\"\n# Definition for Employee.\nclass Employee:\n    def __init__(self, id: int, importance: int, subordinates: List[int]):\n        self.id = id\n        self.importance = importance\n        self.subordinates = subordinates\n\"\"\"\n\nclass Solution:\n    def getImportance(self, employees: List['Employee'], id: int) -> int:\n        "}, {"value": "csharp", "text": "C#", "defaultCode": "/*\n// Definition for Employee.\nclass Employee {\n    public int id;\n    public int importance;\n    public IList<int> subordinates;\n}\n*/\n\nclass Solution {\n    public int GetImportance(IList<Employee> employees, int id) {\n        \n    }\n}"}, {"value": "javascript", "text": "JavaScript", "defaultCode": "/**\n * Definition for Employee.\n * function Employee(id, importance, subordinates) {\n *     this.id = id;\n *     this.importance = importance;\n *     this.subordinates = subordinates;\n * }\n */\n\n/**\n * @param {Employee[]} employees\n * @param {number} id\n * @return {number}\n */\nvar GetImportance = function(employees, id) {\n    \n};"}, {"value": "typescript", "text": "TypeScript", "defaultCode": "/**\n * Definition for Employee.\n * class Employee {\n *     id: number\n *     importance: number\n *     subordinates: number[]\n *     constructor(id: number, importance: number, subordinates: number[]) {\n *         this.id = (id === undefined) ? 0 : id;\n *         this.importance = (importance === undefined) ? 0 : importance;\n *         this.subordinates = (subordinates === undefined) ? [] : subordinates;\n *     }\n * }\n */\n\nfunction getImportance(employees: Employee[], id: number): number {\n\t\n};"}, {"value": "php", "text": "PHP", "defaultCode": "/**\n * Definition for Employee.\n * class Employee {\n *     public $id = null;\n *     public $importance = null;\n *     public $subordinates = array();\n *     function __construct($id, $importance, $subordinates) {\n *         $this->id = $id;\n *         $this->importance = $importance;\n *         $this->subordinates = $subordinates;\n *     }\n * }\n */\n\nclass Solution {\n    /**\n     * @param Employee[] $employees\n     * @param Integer $id\n     * @return Integer\n     */\n    function getImportance($employees, $id) {\n        \n    }\n}"}, {"value": "swift", "text": "Swift", "defaultCode": "/**\n * Definition for Employee.\n * public class Employee {\n *     public var id: Int\n *     public var importance: Int\n *     public var subordinates: [Int]\n *     public init(_ id: Int, _ importance: Int, _ subordinates: [Int]) {\n *         self.id = id\n *         self.importance = importance\n *         self.subordinates = subordinates\n *     }\n * }\n */\n\nclass Solution {\n    func getImportance(_ employees: [Employee], _ id: Int) -> Int {\n        \n    }\n}"}, {"value": "kotlin", "text": "Kotlin", "defaultCode": "/*\n *\t// Definition for Employee.\n *\tclass Employee {\n *\t\tvar id:Int = 0\n *\t\tvar importance:Int = 0\n *\t\tvar subordinates:List<Int> = listOf()\n *\t}\n */\n\nclass Solution {\n    fun getImportance(employees: List<Employee?>, id: Int): Int {\n        \n    }\n}"}, {"value": "golang", "text": "Go", "defaultCode": "/**\n * Definition for Employee.\n * type Employee struct {\n *     Id int\n *     Importance int\n *     Subordinates []int\n * }\n */\n\nfunc getImportance(employees []*Employee, id int) int {\n    \n}"}, {"value": "ruby", "text": "Ruby", "defaultCode": "=begin\n# Definition for Employee.\nclass Employee\n    attr_accessor :id, :importance, :subordinates\n    def initialize( id, importance, subordinates)\n        @id = id\n        @importance = importance\n        @subordinates = subordinates\n    end\nend\n=end\n\n# @param {Employee} employees\n# @param {Integer} id\n# @return {Integer}\ndef get_importance(employees, id)\n    \nend"}, {"value": "scala", "text": "Scala", "defaultCode": "/*\n// Definition for Employee.\nclass Employee() {\n    var id: Int = 0\n    var importance: Int = 0\n    var subordinates: List[Int] = List()\n};\n*/\n\nobject Solution {\n    def getImportance(employees: List[Employee], id: Int): Int = {\n        \n    }\n}"}]
{
  "name": "getImportance",
  "params": [
    {
      "name": "employees",
      "type": "list<string>"
    },
    {
      "name": "id",
      "type": "integer"
    }
  ],
  "return": {
    "type": "integer"
  },
  "languages": [
    "cpp",
    "java",
    "python",
    "ruby",
    "python3",
    "kotlin",
    "scala",
    "csharp",
    "javascript",
    "swift",
    "golang",
    "php",
    "typescript"
  ],
  "manual": true,
  "typescriptCustomType":"class Employee {\n    id: number;\n    importance: number;\n    subordinates: number[];\n    constructor(id: number, importance: number, subordinates: number[]) {\n        this.id = (id === undefined) ? 0 : id;\n        this.importance = (importance === undefined) ? 0 : importance;\n        this.subordinates = (subordinates === undefined) ? [] : subordinates;\n    }\n}"
  
}
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressSanitizer</a> is also enabled to help detect out-of-bounds and use-after-free bugs.</p>\r\n\r\n<p>Most standard library headers are already included automatically for your convenience.</p>"], "java": ["Java", "<p><code>OpenJDK 21</code>. Using compile arguments: <code>--enable-preview --release 21</code></p>\r\n\r\n<p>Most standard library headers are already included automatically for your convenience.</p>\r\n<p>Includes <code>Pair</code> class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.</p>"], "python": ["Python", "<p><code>Python 2.7.18</code>.</p>\r\n\r\n<p>Most libraries are already imported automatically for your convenience, such as <a href=\"https://docs.python.org/2/library/array.html\" target=\"_blank\">array</a>, <a href=\"https://docs.python.org/2/library/bisect.html\" target=\"_blank\">bisect</a>, <a href=\"https://docs.python.org/2/library/collections.html\" target=\"_blank\">collections</a>. If you need more libraries, you can import it yourself.</p>\r\n\r\n<p>For Map/TreeMap data structure, you may use <a href=\"http://www.grantjenks.com/docs/sortedcontainers/\" target=\"_blank\">sortedcontainers</a> library.</p>\r\n\r\n<p>Note that Python 2.7 <a href=\"https://www.python.org/dev/peps/pep-0373/\" target=\"_blank\">is not maintained anymore</a>. For the latest Python, please choose Python3 instead.</p>"], "csharp": ["C#", "<p><a href=\"https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13\" target=\"_blank\">C# 13</a> with .NET 9 runtime</p>"], "javascript": ["JavaScript", "<p><code>Node.js 22.14.0</code>.</p>\r\n\r\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\"http://node.green/\" target=\"_blank\">new ES6 features</a>.</p>\r\n\r\n<p><a href=\"https://lodash.com\" target=\"_blank\">lodash.js</a> library is included by default.</p>\r\n\r\n<p>For Priority Queue / Queue data structures, you may use 6.3.2 version of <a href=\"https://github.com/datastructures-js/priority-queue/tree/v6.3.2\" target=\"_blank\">datastructures-js/priority-queue</a> and 4.2.3 version of <a href=\"https://github.com/datastructures-js/queue/tree/v4.2.3\" target=\"_blank\">datastructures-js/queue</a> and 1.0.4 version of <a href=\"https://github.com/datastructures-js/deque/tree/v1.0.4\" target=\"_blank\">datastructures-js/deque</a>.</p>"], "ruby": ["Ruby", "<p><code>Ruby 3.2</code></p>\r\n\r\n<p>Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms</p>"], "swift": ["Swift", "<p><code>Swift 6.0</code>.</p>\r\n\r\n<p>You may use the following packages:<br/>\r\n<a href=\"https://github.com/apple/swift-algorithms/tree/1.2.0\" target=\"_blank\">swift-algorithms 1.2.0</a><br/>\r\n<a href=\"https://github.com/apple/swift-collections/tree/1.1.4\" target=\"_blank\">swift-collections 1.1.4</a><br/>\r\n<a href=\"https://github.com/apple/swift-numerics/tree/1.0.2\" target=\"_blank\">swift-numerics 1.0.2</a></p>"], "golang": ["Go", "<p><code>Go 1.23</code></p>\r\n<p>Support <a href=\"https://pkg.go.dev/github.com/emirpasic/gods@v1.18.1\" target=\"_blank\">https://pkg.go.dev/github.com/emirpasic/gods@v1.18.1</a> and <a href=\"https://pkg.go.dev/github.com/emirpasic/gods/v2@v2.0.0-alpha\" target=\"_blank\">https://pkg.go.dev/github.com/emirpasic/gods/v2@v2.0.0-alpha</a> library.</p>"], "python3": ["Python3", "<p><code>Python 3.11</code>.</p>\r\n\r\n<p>Most libraries are already imported automatically for your convenience, such as <a href=\"https://docs.python.org/3/library/array.html\" target=\"_blank\">array</a>, <a href=\"https://docs.python.org/3/library/bisect.html\" target=\"_blank\">bisect</a>, <a href=\"https://docs.python.org/3/library/collections.html\" target=\"_blank\">collections</a>. If you need more libraries, you can import it yourself.</p>\r\n\r\n<p>For Map/TreeMap data structure, you may use <a href=\"http://www.grantjenks.com/docs/sortedcontainers/\" target=\"_blank\">sortedcontainers</a> library.</p>"], "scala": ["Scala", "<p><code>Scala 3.3.1</code>.</p>"], "kotlin": ["Kotlin", "<p><code>Kotlin 2.1.10</code>.</p>"], "php": ["PHP", "<p><code>PHP 8.2</code>.</p>\r\n<p>With bcmath module</p>"], "typescript": ["Typescript", "<p><code>TypeScript 5.7.3, Node.js 22.14.0</code>.</p>\r\n\r\n<p>Compile Options: <code>--alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2024</code></p>\r\n\r\n<p><a href=\"https://lodash.com\" target=\"_blank\">lodash.js</a> library is included by default.</p>\r\n\r\n<p>For Priority Queue / Queue data structures, you may use 6.3.2 version of <a href=\"https://github.com/datastructures-js/priority-queue/tree/v6.3.2\" target=\"_blank\">datastructures-js/priority-queue</a> and 4.2.3 version of <a href=\"https://github.com/datastructures-js/queue/tree/v4.2.3\" target=\"_blank\">datastructures-js/queue</a> and 1.0.4 version of <a href=\"https://github.com/datastructures-js/deque/tree/v1.0.4\" target=\"_blank\">datastructures-js/deque</a>.</p>"]}
['Array', 'Hash Table', 'Tree', 'Depth-First Search', 'Breadth-First Search']