摘要:
剑指 Offer 66. 构建乘积数组 看到数据范围是$1e5$就大概猜到了不能暴力,尝试了一下也确实TLE了。 class Solution { public int[] constructArr(int[] a) { int n = a.length; int[] res = new int[n 阅读全文
posted @ 2022-02-06 01:04
NullPointer_C
阅读(38)
评论(0)
推荐(0)
摘要:
剑指 Offer 39. 数组中出现次数超过一半的数字 一个比较简单的办法就是哈希计数,统计次数大于$\frac{n}{2}$的数字。 class Solution { public int majorityElement(int[] nums) { int res = -1, n = nums.l 阅读全文
posted @ 2022-02-06 00:41
NullPointer_C
阅读(38)
评论(0)
推荐(0)

浙公网安备 33010602011771号