C++solution


  • 0
    H

    int getImportance(vector<Employee*> employees, int id) {
    int sum = 0;
    for(int i=0;i<employees.size();i++){
    if(id == employees[i]->id){
    sum += employees[i]->importance;
    vector<int> sub = employees[i]->subordinates;
    for(int j=0;j<sub.size();j++){
    sum+=getImportance(employees,sub[j]);
    }
    }
    }
    return sum;

    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.