File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < stdio.h>
2
+ #include < malloc.h>
3
+ #include < string.h>
4
+
5
+ bool containsDuplicate (int * nums, int numsSize) {
6
+ char * pflag = (char *)malloc (1000000001 );
7
+ char * mflag = (char *)malloc (1000000001 );
8
+ memset (pflag, 0 , 1000000001 );
9
+ memset (mflag, 0 , 1000000001 );
10
+ for (int i = 0 ; i < numsSize; ++i) {
11
+ if (nums[i] < 0 ) {
12
+ if (mflag[-nums[i]] == 1 ) {
13
+ free (pflag);
14
+ free (mflag);
15
+ return true ;
16
+ }
17
+ mflag[-nums[i]] = 1 ;
18
+ }
19
+ else {
20
+ if (pflag[nums[i]] == 1 ) {
21
+ free (pflag);
22
+ free (mflag);
23
+ return true ;
24
+ }
25
+ pflag[nums[i]] = 1 ;
26
+ }
27
+ }
28
+ free (pflag);
29
+ free (mflag);
30
+ return false ;
31
+ }
32
+
33
+ void main (void ) {
34
+ int test[100001 ] = {0 };
35
+ printf (" %d\n " , containsDuplicate (test, 1 ));
36
+ }
You can’t perform that action at this time.
0 commit comments