Boyer-Moore voting algo easy C++ solution


#1

int Solution::majorityElement(const vector &A) {
int count = 0;
int num;

for(auto i : A) {
    if(count == 0) {
        num = i;
    }
    count  += (num == i ? +1 : -1);
}
return num;

}