Magicsheet logo

Number of Employees Who Met the Target

Easy
26.5%
Updated 6/1/2025

Asked by 2 Companies

Topics

Number of Employees Who Met the Target

What is this problem about?

The Number of Employees Who Met the Target problem gives you an array of hours worked by employees and a target value. Count how many employees worked at least the target number of hours. This is the simplest possible array filtering problem.

Why is this asked in interviews?

TCS and Amazon ask this easy problem as a quick coding screening to verify that candidates can write a basic array traversal with a conditional count. The array interview pattern is demonstrated at its most fundamental.

Algorithmic pattern used

Linear scan with counter. Traverse the array. For each value ≥ target, increment a counter. Return the counter. Can also be written as sum(1 for h in hours if h >= target).

Example explanation

Hours: [0, 1, 2, 3, 4, 5], target=3. Values ≥ 3: 3, 4, 5. Count = 3.

Hours: [5, 1, 4, 2, 2], target=6. No value ≥ 6. Count = 0.

Common mistakes candidates make

  • Using > target instead of >= target (must include target itself).
  • Off-by-one in loop bounds.
  • Returning the sum of values instead of the count.
  • Not handling an empty array (return 0).

Interview preparation tip

Easy array counting problems test implementation speed and precision. The >= vs > distinction in threshold conditions is a common interview trap. Always re-read the problem statement to verify whether the threshold is inclusive or exclusive. Practice translating word problems ("at least," "more than," "no more than") to their corresponding comparison operators (>=, >, <=) quickly and accurately.

Similar Questions