LC.P2455[可被三整除的偶数的平均值] 方法一:模拟123456789101112class Solution { public int averageValue(int[] nums) { int sum = 0, cnt = 0; for (int num : nums) { if (num % 6 == 0) { ++cnt; sum += num; } } return cnt == 0 ? 0 : sum / cnt; }} 时间复杂度:$O(n)$ 空间复杂度:$O(1)$