LeetCode每日一题----2798号员工工作时长统计
发布时间
阅读量:
阅读量
LeetCode 每日一题 ---- 【2798.满足目标工作时长的员工数目】
-
- 达到规定工作时长标准的员工数量
-
- 途径:对数组进行逐项检查
目标工作时长达标员工统计
方法:遍历数组
对数组进行逐一检查,确认其中各元素是否符合特定要求
class Solution {
public int numberOfEmployeesWhoMetTarget(int[] hours, int target) {
int ans = 0;
for (Integer hour : hours) {
if (hour >= target) ans ++ ;
}
return ans;
}
}
时间复杂度:
算法执行过程中所需的时间资源规模为O(n)。
空间复杂度:
算法运行时所占用的存储空间规模为O(1)。
全部评论 (0)
还没有任何评论哟~
