Skip to content

Commit d84be8f

Browse files
committed
contains-duplicate solution
1 parent 0057ff1 commit d84be8f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

contains-duplicate/rlawjd10.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
int compare(const void* a, const void* b) {
2+
return (*(int*)a - *(int*)b); // 오름차순
3+
}
4+
5+
bool containsDuplicate(int* nums, int numsSize) {
6+
qsort(nums, numsSize, sizeof(int), compare);
7+
8+
for (int i = 1; i < numsSize; i++) {
9+
if (nums[i] == nums[i-1])
10+
return 1;
11+
}
12+
return 0;
13+
}
14+

0 commit comments

Comments
 (0)