bool containsDuplicate(int* nums, int numsSize) {
int i,j;
int key;
for(i=1; i<numsSize; i++){
j = i1;
key = nums[i];
while (j>=0 && nums[j]>key){
nums[j+1] = nums[j];
j;
}
if(j>=0 && nums[j] == key) return true;
nums[j+1] = key;
}
// for(i=1; i<numsSize; i++) if(nums[i1] == nums[i]) return true;
return false;
}
12 ms C solution , is it right?


@wuhan326 Actually you've already finished that
comparing
while doing yourinsertSort
.while (j>0 && nums[j]>key) if(nums[j] == key) return true;