/** * * @param numbers int整型一维数组 * @param numbersLen int numbers数组长度 * @return int整型 */ int MoreThanHalfNum_Solution(int* numbers, int numbersLen ) { // write code here int L1=1; int L2=0; for(L1 = 1, L2 = 0; (L1 < numbersLen) && (L2 < numbersLen); ) { while(numbers[L2] == -1) { L2++; } if(L1 == L2) { L1++; continue; } if(numbers[L1] != numbers[L2]) { numbers[L1] = numbers[L2] = -1; L1++; L2++; } else { L1++; } } while(numbers[L2] == -1) { L2++; } return numbers[L2]; }