Skip to content

Commit 64f3f35

Browse files
committed
690. Employee Importance
1 parent df3fc89 commit 64f3f35

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

employee-importance.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)