leetcode-剑指03-OK
int findRepeatNumber(int* nums, int numsSize){
int a;
int findone(int m){
int n = nums[m];
nums[m] = -1;
while((n!=-1)&&(nums[n] != n)){
m = nums[n];
nums[n] = n;
n = m;
}
return n;
}
for(int i = 0; i< numsSize; i++){
if(nums[i] != i){
a = i;
a = findone(a);
if(a!=-1)
return a;
}
}
return -1;
}