mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
14 lines
306 B
C
14 lines
306 B
C
|
int numcmp(const void *a, const void *b) {
|
||
|
return *(int *)a - *(int *)b;
|
||
|
}
|
||
|
|
||
|
bool containsDuplicate(int* nums, int numsSize){
|
||
|
int i;
|
||
|
qsort(nums, numsSize, sizeof(int), numcmp);
|
||
|
for (i = 0; i < numsSize - 1; i++) {
|
||
|
if(nums[i] == nums[i+1])
|
||
|
return 1;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|