Number of Employees Who Met the Target - Problem
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.
Input & Output
Example 1 — Basic Case
$
Input:
hours = [0,1,2,3,4], target = 2
›
Output:
3
💡 Note:
Employees with indices 2, 3, and 4 worked at least 2 hours: hours[2] = 2, hours[3] = 3, hours[4] = 4
Example 2 — All Meet Target
$
Input:
hours = [5,1,4,2,2], target = 1
›
Output:
5
💡 Note:
All employees worked at least 1 hour, so all 5 employees meet the target
Example 3 — None Meet Target
$
Input:
hours = [1,2,3], target = 5
›
Output:
0
💡 Note:
No employee worked 5 or more hours, so 0 employees meet the target
Constraints
- 1 ≤ n ≤ 50
- 0 ≤ hours[i], target ≤ 105
Visualization
Tap to expand
Understanding the Visualization
1
Input
Array of employee hours and target requirement
2
Process
Count employees with hours >= target
3
Output
Number of qualifying employees
Key Takeaway
🎯 Key Insight: Simply iterate through the array once and count elements >= target
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code