---
# System prepended metadata

title: 217. Contains Duplicate

---

# 217. Contains Duplicate




PonPon
===

``` c=
int cmp(const void *a, const void *b){
   return *(int*)a-*(int*)b;
}

bool containsDuplicate(int* nums, int numsSize){
    int i=0, j=0;
    
    if (numsSize == 1)
        return false;
    qsort(nums, numsSize, sizeof(int), cmp);
    for (i=0;i<numsSize-1;i++) {
        if (nums[i] == nums[i+1])
            return true;
    }
    return false;
}
time complexity: O(n log n)
space complexity: O(1)
Comment: Search qsort in web, need to implement merge sort

```