注意題目給的最後一句話,如果部門任何employee都做不同型別的工作,則這個部門是一個diverse,題目是計算department的diverse數
讀起來感覺有點彆扭,英語沒學好的原因
int countGood(vector <int> superior, vector <int> workType) { int res = 0; for(int i = 0 ; i < superior.size(); ++ i){ set<int> department; department.insert(workType[i]); int num = 1; for(int j = i+1; j < superior.size(); ++ j ){ if(superior[j] == i){ department.insert(workType[j]); num++; } } if(num == department.size()) res++; } return res; }