Skip to content

2798. Number of Employees Who Met the Target 👍

  • Time: $O(n)$
  • Space: $O(1)$
1
2
3
4
5
6
7
class Solution {
 public:
  int numberOfEmployeesWhoMetTarget(vector<int>& hours, int target) {
    return ranges::count_if(hours,
                            [target](int hour) { return hour >= target; });
  }
};
1
2
3
4
5
class Solution {
  public int numberOfEmployeesWhoMetTarget(int[] hours, int target) {
    return (int) Arrays.stream(hours).filter(hour -> hour >= target).count();
  }
}
1
2
3
class Solution:
  def numberOfEmployeesWhoMetTarget(self, hours: list[int], target: int) -> int:
    return sum(hour >= target for hour in hours)