视频:https://www.acwing.com/video/176/
class Solution { public: int moreThanHalfNum_Solution(vector<int>& nums) { int cnt = 1,val = nums[0]; for(int i=1;i<nums.size();i++) { if(nums[i] == val) cnt++; else cnt--; if(cnt == 0) { val = nums[i]; cnt=1; } } return val; } };