[LeetCode] Number of Employees Who Met the Target

2798. Number of Employees Who Met the Target

There are n employees in a company, numbered from 0 to n - 1. Each employee i has worked for hours[i] hours in the company.

The company requires each employee to work for at least target hours.

You are given a 0-indexed array of non-negative integers hours of length n and a non-negative integer target.

Return the integer denoting the number of employees who worked at least target hours.

1
2
3
4
5
6
7
8
9
class Solution {
public:
int numberOfEmployeesWhoMetTarget(vector<int>& hours, int target) {
int res = 0;
for(auto& h : hours) if(h >= target) res += 1;
return res;
}
};

Author: Song Hayoung
Link: https://songhayoung.github.io/2023/07/30/PS/LeetCode/number-of-employees-who-met-the-target/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.