#2798
Number of Employees Who Met the Target
newbie · 105 · lc easy +12 · verified · 87.8% accepted · 602 likes · top 98%
Description
A company has n employees numbered 0 to n - 1. Employee i worked hours[i] hours. The company requires at least target hours of work.
Given a 0-indexed array hours and a non-negative integer target, return the count of employees who worked at least target hours.
Example 1:
Input: hours = [0,1,2,3,4], target = 2
Output: 3
Explanation: The company wants each employee to work for at least 2 hours.
- Employee 0 worked for 0 hours and didn't meet the target.
- Employee 1 worked for 1 hours and didn't meet the target.
- Employee 2 worked for 2 hours and met the target.
- Employee 3 worked for 3 hours and met the target.
- Employee 4 worked for 4 hours and met the target.
There are 3 employees who met the target.
Example 2:
Input: hours = [5,1,4,2,2], target = 6
Output: 0
Explanation: The company wants each employee to work for at least 6 hours.
There are 0 employees who met the target.
Code
1
2
3