Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions src/NumberOfEmployeesWhoMetTheTarget2798.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Tags: Array
package com.leetcode.easy;

public class NumberOfEmployeesWhoMetTheTarget2798 {
/**
* Time Complexity: O(n) where n is the length of the hours array
* - We iterate through the entire array once
* - Each element is checked exactly once
* <p>
* Space Complexity: O(1)
* - Only uses a constant amount of extra space (variables res and hour)
* - No additional data structures are allocated
*/
public int numberOfEmployeesWhoMetTarget(int[] hours, int target) {
int res = 0;
for (int hour : hours) {
if (hour >= target) {
res++;
}
}
return res;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.leetcode.easy;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class NumberOfEmployeesWhoMetTheTarget2798Test {
private NumberOfEmployeesWhoMetTheTarget2798 solution;

@BeforeEach
void setUp() {
solution = new NumberOfEmployeesWhoMetTheTarget2798();
}

@Test
void testNumberOfEmployeesWhoMetTarget_Example1() {
int[] hours = {0, 1, 2, 3, 4};
int target = 2;

int result = solution.numberOfEmployeesWhoMetTarget(hours, target);

assertEquals(3, result);
}

@Test
void testNumberOfEmployeesWhoMetTarget_Example2() {
int[] hours = {5, 1, 4, 2, 3};
int target = 6;

int result = solution.numberOfEmployeesWhoMetTarget(hours, target);

assertEquals(0, result);
}
Comment on lines +16 to +34

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test coverage is limited to basic examples. Consider adding tests for important edge cases such as:

  1. An empty array (if allowed by problem constraints)
  2. A single-element array where the element meets the target
  3. A single-element array where the element doesn't meet the target
  4. An array where all employees meet the target
  5. Boundary condition where hours exactly equal the target (already partially covered in Example1 but could be more explicit)

These additional tests would help ensure the solution handles all scenarios correctly.

Copilot uses AI. Check for mistakes.
}
Loading