We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent df3fc89 commit 64f3f35Copy full SHA for 64f3f35
employee-importance.cpp
@@ -0,0 +1,29 @@
1
+//Runtime: 22 ms
2
+class Solution {
3
+public:
4
+ int getImportance(vector<Employee*> employees, int id) {
5
+ int ans = 0;
6
+ queue<int>Q;
7
+ Q.push(id);
8
+
9
+ while(!Q.empty())
10
+ {
11
+ int t = Q.front();
12
+ Q.pop();
13
14
+ for(auto it:employees)
15
16
+ if(it->id == t)
17
18
+ ans+=it->importance;
19
20
+ for(int emp:it->subordinates)
21
+ Q.push(emp);
22
23
+ break;
24
+ }
25
26
27
+ return ans;
28
29
+};
0 commit comments