摘要:
T1: 分割圆的最少切割次数 思维题: n 为偶数时,可以对半切割,切割 $\frac{n}{2}$次即可 n 为奇数时,不满足对称性,需要切割 n 次 n 为 1 时,不需要切割 public int numberOfCuts(int n) { if (n == 1) { return 0; } 阅读全文
摘要:
T1: 不同的平均值数目 思路:排序 + 双指针 + 哈希存储 public int distinctAverages(int[] nums) { Arrays.sort(nums); Set<Double> set = new HashSet<>(); int i = 0, j = nums.le 阅读全文
摘要:
T1: 对数组执行操作 思路:模拟 public int[] applyOperations(int[] nums) { int n = nums.length; for (int i = 0; i < n - 1; ++i) { if (nums[i] == nums[i + 1]) { nums 阅读全文
摘要:
T1: 可被3整数的偶数的平均值 思路:数组遍历 被3整数的偶数 $\Leftrightarrow$ 被6整数的数 public int averageValue(int[] nums) { int sum = 0; int count = 0; for (int num : nums) { if 阅读全文