https://blog.youkuaiyun.com/qq_43414142/article/details/98068177
bool findMaxNum(int a[],int len, int* ret) {
if (a == NULL || len == 0) {
return false;
}
int count = 1;
int result = a[0];
for (int i =1; i<len;i++) {
if (count == 0) {
result = a[i];
}
if (a[i] == result) {
count++;
}
else {
count--;
}
}
int totalCount = 0;
for (int j =0 ; j < len; j++) {
if (a[j] == result) {
totalCount++;
}
}
return totalCount>len/2?true:false;
}
int maxNum[] = {1, 2, 2, 2, 2, 2, 2, 8, 9, 10};
int maxNumRet;
bool maxNumRetBool = findMaxNum(maxNum,10,&maxNumRet);