Skip to main content
Back to problems
#2798
Easy Algorithms

Number of employees who met the target

Array
87.8% acceptance
Feb 25, 2026
602
77
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.

Solution

Rust
Time O(n)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn number_of_employees_who_met_target(hours: Vec<i32>, target: i32) -> i32 {
    hours.iter().filter(|&&h| h >= target).count() as i32
  }
}