题目描述
blablabla
样例
blablabla
算法1
class Solution {
public:
int moreThanHalfNum_Solution(vector<int>& nums) {
int count=0,candidate;
for (auto num : nums) {
if (count==0) {
candidate=num;
}
if (candidate==num) {
count++;
}
else count--;
}
return candidate;
}
};