4 Line c++ code


#1

int Solution::majorityElement(const vector &a) {
int e,c = 0;
for(auto i:a){
if( c) {c+=i==e?1:-1;}
else {e = i;c=1;}
}
return e;
}