class Solution {
public:
/**
* @param nums: A list of integers
* @return: The majority number
*/
int majorityNumber(vector<int> nums) {
// write your code here
int count=1;
int temp=nums[0];
int n=nums.size();
for(int i=1;i<n;i++){
if(nums[i]==temp)
count++;
else
count--;
if(count==0){
temp=nums[i];
count++;
}
}
return temp;
}
};