Majority Number III
题目:
Given an array of integers and a number k, the majority number is the number that occurs more than 1/k of the size of the array.
分析:
k数抵消,用大小为k-1的hashmap, 发现k数时,把前k-1的个数都减少一个
偷懒直接用了最大count的数
解法:
Last updated
题目:
Given an array of integers and a number k, the majority number is the number that occurs more than 1/k of the size of the array.
分析:
k数抵消,用大小为k-1的hashmap, 发现k数时,把前k-1的个数都减少一个
偷懒直接用了最大count的数
解法:
Last updated