Problem Description
Given an array representing the number of hours each employee has worked and a target number of hours required, count how many employees have met or exceeded the target hours.
Key Insights
- You are given a list of non-negative integers representing work hours.
- A simple iteration through the array is sufficient since the constraints are small.
- Increment a counter each time an employee's hours are greater than or equal to the target.
- The solution is straightforward with a single loop.
Space and Time Complexity
Time Complexity: O(n), where n is the number of employees. Space Complexity: O(1), only a counter is used.
Solution
The approach is to iterate over the list of work hours and count the number of employees whose hours are at least the target. Use a simple counter variable initialized to 0, and for every value in the array, increment the counter if the value is greater than or equal to the target. This yields a time-efficient and space-efficient solution. The key data structure is the array provided, and the algorithmic approach is a single linear scan.