EasyNo. 2798
Number of Employees Who Met the Target — LeetCode 2798 Python Solution
- Topics
- Array
- Reading time
- 2 min
- Source
- leetcode.com
The 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.
Example
- Input
- hours = [0,1,2,3,4], target = 2
- Output
- 3
- Explanation
- The company wants each employee to work for at least 2 hours.
Python solution
class Solution:
def numberOfEmployeesWhoMetTarget(self, hours: List[int], target: int) -> int:
return sum(x >= target for x in hours)Complexity
- Time
- O(n)where n is the length of the array hours
- Space · auxiliary
- O(1)
Related problems
| No. | Problem | Difficulty |
|---|---|---|
| 0057 | Insert Interval | Medium |
| 0228 | Summary Ranges | Easy |
| 0485 | Max Consecutive Ones | Easy |
| 0665 | Non-decreasing Array | Medium |
| 0674 | Longest Continuous Increasing Subsequence | Easy |
| 0699 | Falling Squares | Hard |
Frequently asked questions
- How hard is LeetCode 2798. Number of Employees Who Met the Target?
LeetCode 2798. Number of Employees Who Met the Target is rated Easy on LeetCode.
- What is the time complexity of LeetCode 2798. Number of Employees Who Met the Target?
The Python solution on this page runs in O(n), where n is the length of the array hours.
- What is the space complexity of LeetCode 2798. Number of Employees Who Met the Target?
The Python solution on this page uses O(1) auxiliary space.
- What topics does LeetCode 2798. Number of Employees Who Met the Target cover?
LeetCode 2798. Number of Employees Who Met the Target is tagged Array on LeetCode.