Number of Employees Who Met the Target

We need to find the number of employees who have worked at least target hours. We can achieve this by iterating through the hours array and counting the number of elements that are greater than or equal to the target.

Here’s the code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class Solution:
    def numberOfEmployeesWhoMetTarget(self, hours: List[int], target: int) -> int:
        # Initialize the count of employees who met the target
        count = 0

        # Iterate through the array of hours
        for hour in hours:
            # If the employee has worked at least target hours, increment the count
            if hour >= target:
                count += 1

        # Return the final count
        return count

This code has a time complexity of (O(n)) where (n) is the number of employees, and a space complexity of (O(1)).