Input: hours =[0,1,2,3,4], target =2Output: 3Explanation: The company wants each employee to work for at least 2 hours.- Employee 0 worked for0 hours and didn't meet the target.- Employee 1 worked for1 hours and didn't meet the target.- Employee 2 worked for2 hours and met the target.- Employee 3 worked for3 hours and met the target.- Employee 4 worked for4 hours and met the target.There are 3 employees who met the target.
Input: hours =[5,1,4,2,2], target =6Output: 0Explanation: The company wants each employee to work for at least 6 hours.There are 0 employees who met the target.
#include<vector>usingnamespace std;
classSolution {
public:int numberOfEmployeesWhoMetTarget(vector<int>& hours, int target) {
int ans =0;
for (int h : hours) if (h >= target) ++ans;
return ans;
}
};
classSolution {
publicintnumberOfEmployeesWhoMetTarget(int[] hours, int target) {
int ans = 0;
for (int h : hours) if (h >= target) ans++;
return ans;
}
}