Majority Number II
题目:
Given an array of integers, the majority number is the number that occurs more than 1/3 of the size of the array.
分析:
3个数不一样就扔掉, 出现一个不一样的数,用新数抵消掉前俩数,注意最后还需要一个loop 比较2个candidates.
解法:
Last updated
题目:
Given an array of integers, the majority number is the number that occurs more than 1/3 of the size of the array.
分析:
3个数不一样就扔掉, 出现一个不一样的数,用新数抵消掉前俩数,注意最后还需要一个loop 比较2个candidates.
解法:
Last updated