lcp356 第一题 满足目标工作时长的员工数目 方法一:模拟 123456789class Solution { public int numberOfEmployeesWhoMetTarget(int[] hours, int target) { int res = 0; for (int x : hours) if (x >= target) ++res; return res; }} 第二题统计完全子数组的数目 方法一:HashSet 12345678910111213141516171819class Solution { public int countCompleteSubarrays(int[] nums) { Set<Integer> set = new HashSet<>(); for (int x : nums) set.add(x); int length = set.size(), res = 0, n = nums.length; // 以第i位结尾,有多少完全子数组,i >= length for (int i = length - 1; i < n; ++i) { Set s = new HashSet(); for (int j = i; j >= 0; --j) { s.add(nums[j]); if (s.size() == length) { ++res; } } } return res; }} 第三题包含三个字符串的最短字符串 方法一: 1 第四题 方法一: 1 2719. 统计整数数目 2376. 统计特殊整数 Contest > LCP #力扣杯 lcp356 https://leopol1d.github.io/2023/07/30/lcp356/ 作者 Leopold 发布于 2023年7月30日 许可协议 Digit Dynamic Programming 上一篇 Binary Index Tree 下一篇 Please enable JavaScript to view the comments