JuniorArray

Number of Employees Who Met the Target

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.

Example 1
Inputhours = [0,1,2,3,4], target = 2
Output3
Employees 2, 3, and 4 worked at least 2 hours, so 3 employees met the target.
Example 2
Inputhours = [5,1,4,2,2], target = 6
Output0
No employee worked at least 6 hours, so 0 employees met the target.

Constraints

  • 1 <= n == hours.length <= 50
  • 0 <= hours[i], target <= 10^5

Asked at 2 companies

Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, what to keep, what's wrong, and the complexity of your solution.

Sign in to evaluate