From a48c32e01ed01d44332123b3762def53e528b413 Mon Sep 17 00:00:00 2001 From: csucom Date: Sun, 24 Nov 2024 22:40:24 +0900 Subject: [PATCH 01/17] add sample code for testing --- 3sum/csucom.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 3sum/csucom.py diff --git a/3sum/csucom.py b/3sum/csucom.py new file mode 100644 index 000000000..9def7cf98 --- /dev/null +++ b/3sum/csucom.py @@ -0,0 +1,3 @@ +''' + test code +''' \ No newline at end of file From aa2e678ca6b1d47e6115e269f4681aa41f75e2fa Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 00:10:51 +0900 Subject: [PATCH 02/17] contains-duplicate --- contains-duplicate/jejufather.cpp | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 contains-duplicate/jejufather.cpp diff --git a/contains-duplicate/jejufather.cpp b/contains-duplicate/jejufather.cpp new file mode 100644 index 000000000..2b2418ea6 --- /dev/null +++ b/contains-duplicate/jejufather.cpp @@ -0,0 +1,36 @@ +#include +#include +#include + +bool containsDuplicate(int* nums, int numsSize) { + char* pflag = (char*)malloc(1000000001); + char* mflag = (char*)malloc(1000000001); + memset(pflag, 0, 1000000001); + memset(mflag, 0, 1000000001); + for (int i = 0; i < numsSize; ++i) { + if (nums[i] < 0) { + if (mflag[-nums[i]] == 1) { + free(pflag); + free(mflag); + return true; + } + mflag[-nums[i]] = 1; + } + else { + if (pflag[nums[i]] == 1) { + free(pflag); + free(mflag); + return true; + } + pflag[nums[i]] = 1; + } + } + free(pflag); + free(mflag); + return false; +} + +void main(void) { + int test[100001] = {0}; + printf("%d\n", containsDuplicate(test, 1)); +} \ No newline at end of file From cc905f54fa2ad90e2a2830069641ea1b252acfb3 Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 00:29:27 +0900 Subject: [PATCH 03/17] contains-duplicate --- contains-duplicate/jejufather.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/contains-duplicate/jejufather.cpp b/contains-duplicate/jejufather.cpp index 2b2418ea6..81221d523 100644 --- a/contains-duplicate/jejufather.cpp +++ b/contains-duplicate/jejufather.cpp @@ -30,6 +30,7 @@ bool containsDuplicate(int* nums, int numsSize) { return false; } + void main(void) { int test[100001] = {0}; printf("%d\n", containsDuplicate(test, 1)); From c3e92cfecb4ecf6e9945af6e1fcc1063569b5f05 Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 00:31:46 +0900 Subject: [PATCH 04/17] Delete 3sum/csucom.py --- 3sum/csucom.py | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 3sum/csucom.py diff --git a/3sum/csucom.py b/3sum/csucom.py deleted file mode 100644 index 9def7cf98..000000000 --- a/3sum/csucom.py +++ /dev/null @@ -1,3 +0,0 @@ -''' - test code -''' \ No newline at end of file From 7ed155864f2fa6c8da8a4a78de0ed7a13215942c Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 00:36:08 +0900 Subject: [PATCH 05/17] contains-duplicate --- contains-duplicate/jejufather.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contains-duplicate/jejufather.cpp b/contains-duplicate/jejufather.cpp index 81221d523..61544a620 100644 --- a/contains-duplicate/jejufather.cpp +++ b/contains-duplicate/jejufather.cpp @@ -30,8 +30,7 @@ bool containsDuplicate(int* nums, int numsSize) { return false; } - void main(void) { int test[100001] = {0}; printf("%d\n", containsDuplicate(test, 1)); -} \ No newline at end of file +} From 85aa203fe129599b815115462af85b7916e9cbe3 Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 00:48:05 +0900 Subject: [PATCH 06/17] contains-duplicate --- contains-duplicate/csucom.cpp | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 contains-duplicate/csucom.cpp diff --git a/contains-duplicate/csucom.cpp b/contains-duplicate/csucom.cpp new file mode 100644 index 000000000..61544a620 --- /dev/null +++ b/contains-duplicate/csucom.cpp @@ -0,0 +1,36 @@ +#include +#include +#include + +bool containsDuplicate(int* nums, int numsSize) { + char* pflag = (char*)malloc(1000000001); + char* mflag = (char*)malloc(1000000001); + memset(pflag, 0, 1000000001); + memset(mflag, 0, 1000000001); + for (int i = 0; i < numsSize; ++i) { + if (nums[i] < 0) { + if (mflag[-nums[i]] == 1) { + free(pflag); + free(mflag); + return true; + } + mflag[-nums[i]] = 1; + } + else { + if (pflag[nums[i]] == 1) { + free(pflag); + free(mflag); + return true; + } + pflag[nums[i]] = 1; + } + } + free(pflag); + free(mflag); + return false; +} + +void main(void) { + int test[100001] = {0}; + printf("%d\n", containsDuplicate(test, 1)); +} From 622ff7aed7fcaab2fd5b5aed6535ea7675a115b1 Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 09:19:37 +0900 Subject: [PATCH 07/17] Delete contains-duplicate/jejufather.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 올바르지 않은 파일명을 가진 파일 삭제 --- contains-duplicate/jejufather.cpp | 36 ------------------------------- 1 file changed, 36 deletions(-) delete mode 100644 contains-duplicate/jejufather.cpp diff --git a/contains-duplicate/jejufather.cpp b/contains-duplicate/jejufather.cpp deleted file mode 100644 index 61544a620..000000000 --- a/contains-duplicate/jejufather.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include -#include - -bool containsDuplicate(int* nums, int numsSize) { - char* pflag = (char*)malloc(1000000001); - char* mflag = (char*)malloc(1000000001); - memset(pflag, 0, 1000000001); - memset(mflag, 0, 1000000001); - for (int i = 0; i < numsSize; ++i) { - if (nums[i] < 0) { - if (mflag[-nums[i]] == 1) { - free(pflag); - free(mflag); - return true; - } - mflag[-nums[i]] = 1; - } - else { - if (pflag[nums[i]] == 1) { - free(pflag); - free(mflag); - return true; - } - pflag[nums[i]] = 1; - } - } - free(pflag); - free(mflag); - return false; -} - -void main(void) { - int test[100001] = {0}; - printf("%d\n", containsDuplicate(test, 1)); -} From aef971c7ac6b286e43c15acb55b5d0a55a02b790 Mon Sep 17 00:00:00 2001 From: csucom Date: Mon, 9 Dec 2024 09:55:01 +0900 Subject: [PATCH 08/17] contains-duplicate solution --- contains-duplicate/csucom.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contains-duplicate/csucom.cpp b/contains-duplicate/csucom.cpp index 61544a620..1fcb4171e 100644 --- a/contains-duplicate/csucom.cpp +++ b/contains-duplicate/csucom.cpp @@ -1,4 +1,4 @@ -#include +//#include #include #include @@ -30,7 +30,7 @@ bool containsDuplicate(int* nums, int numsSize) { return false; } -void main(void) { - int test[100001] = {0}; - printf("%d\n", containsDuplicate(test, 1)); -} +// void main(void) { +// int test[100001] = {0}; +// printf("%d\n", containsDuplicate(test, 1)); +// } From 1101bc145940719a1194c742bd623171579678ee Mon Sep 17 00:00:00 2001 From: csucom Date: Sun, 24 Nov 2024 22:40:24 +0900 Subject: [PATCH 09/17] add sample code for testing --- 3sum/csucom.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 3sum/csucom.py diff --git a/3sum/csucom.py b/3sum/csucom.py new file mode 100644 index 000000000..9def7cf98 --- /dev/null +++ b/3sum/csucom.py @@ -0,0 +1,3 @@ +''' + test code +''' \ No newline at end of file From 2bb46c531736a8d5a275520331450a4583aae9d2 Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 00:10:51 +0900 Subject: [PATCH 10/17] contains-duplicate --- contains-duplicate/jejufather.cpp | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 contains-duplicate/jejufather.cpp diff --git a/contains-duplicate/jejufather.cpp b/contains-duplicate/jejufather.cpp new file mode 100644 index 000000000..2b2418ea6 --- /dev/null +++ b/contains-duplicate/jejufather.cpp @@ -0,0 +1,36 @@ +#include +#include +#include + +bool containsDuplicate(int* nums, int numsSize) { + char* pflag = (char*)malloc(1000000001); + char* mflag = (char*)malloc(1000000001); + memset(pflag, 0, 1000000001); + memset(mflag, 0, 1000000001); + for (int i = 0; i < numsSize; ++i) { + if (nums[i] < 0) { + if (mflag[-nums[i]] == 1) { + free(pflag); + free(mflag); + return true; + } + mflag[-nums[i]] = 1; + } + else { + if (pflag[nums[i]] == 1) { + free(pflag); + free(mflag); + return true; + } + pflag[nums[i]] = 1; + } + } + free(pflag); + free(mflag); + return false; +} + +void main(void) { + int test[100001] = {0}; + printf("%d\n", containsDuplicate(test, 1)); +} \ No newline at end of file From 07dc83002a66010740c51c4853e11bfb6c357956 Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 00:29:27 +0900 Subject: [PATCH 11/17] contains-duplicate --- contains-duplicate/jejufather.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/contains-duplicate/jejufather.cpp b/contains-duplicate/jejufather.cpp index 2b2418ea6..81221d523 100644 --- a/contains-duplicate/jejufather.cpp +++ b/contains-duplicate/jejufather.cpp @@ -30,6 +30,7 @@ bool containsDuplicate(int* nums, int numsSize) { return false; } + void main(void) { int test[100001] = {0}; printf("%d\n", containsDuplicate(test, 1)); From 1da888d052773e8bb11ed5420758c5e471d3d5e3 Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 00:36:08 +0900 Subject: [PATCH 12/17] contains-duplicate --- contains-duplicate/jejufather.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contains-duplicate/jejufather.cpp b/contains-duplicate/jejufather.cpp index 81221d523..61544a620 100644 --- a/contains-duplicate/jejufather.cpp +++ b/contains-duplicate/jejufather.cpp @@ -30,8 +30,7 @@ bool containsDuplicate(int* nums, int numsSize) { return false; } - void main(void) { int test[100001] = {0}; printf("%d\n", containsDuplicate(test, 1)); -} \ No newline at end of file +} From 84c2e41016cdacf7d45c32603d217192e9703937 Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 00:31:46 +0900 Subject: [PATCH 13/17] Delete 3sum/csucom.py --- 3sum/csucom.py | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 3sum/csucom.py diff --git a/3sum/csucom.py b/3sum/csucom.py deleted file mode 100644 index 9def7cf98..000000000 --- a/3sum/csucom.py +++ /dev/null @@ -1,3 +0,0 @@ -''' - test code -''' \ No newline at end of file From 2750e33526873143b8535c5fdeb53f19cc684adf Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 00:48:05 +0900 Subject: [PATCH 14/17] contains-duplicate --- contains-duplicate/csucom.cpp | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 contains-duplicate/csucom.cpp diff --git a/contains-duplicate/csucom.cpp b/contains-duplicate/csucom.cpp new file mode 100644 index 000000000..61544a620 --- /dev/null +++ b/contains-duplicate/csucom.cpp @@ -0,0 +1,36 @@ +#include +#include +#include + +bool containsDuplicate(int* nums, int numsSize) { + char* pflag = (char*)malloc(1000000001); + char* mflag = (char*)malloc(1000000001); + memset(pflag, 0, 1000000001); + memset(mflag, 0, 1000000001); + for (int i = 0; i < numsSize; ++i) { + if (nums[i] < 0) { + if (mflag[-nums[i]] == 1) { + free(pflag); + free(mflag); + return true; + } + mflag[-nums[i]] = 1; + } + else { + if (pflag[nums[i]] == 1) { + free(pflag); + free(mflag); + return true; + } + pflag[nums[i]] = 1; + } + } + free(pflag); + free(mflag); + return false; +} + +void main(void) { + int test[100001] = {0}; + printf("%d\n", containsDuplicate(test, 1)); +} From 9e53feefd265d5a424b50cb09c27a9d619c06356 Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 23:22:49 +0900 Subject: [PATCH 15/17] delete wrong file --- contains-duplicate/jejufather.cpp | 36 ------------------------------- 1 file changed, 36 deletions(-) delete mode 100644 contains-duplicate/jejufather.cpp diff --git a/contains-duplicate/jejufather.cpp b/contains-duplicate/jejufather.cpp deleted file mode 100644 index 61544a620..000000000 --- a/contains-duplicate/jejufather.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include -#include - -bool containsDuplicate(int* nums, int numsSize) { - char* pflag = (char*)malloc(1000000001); - char* mflag = (char*)malloc(1000000001); - memset(pflag, 0, 1000000001); - memset(mflag, 0, 1000000001); - for (int i = 0; i < numsSize; ++i) { - if (nums[i] < 0) { - if (mflag[-nums[i]] == 1) { - free(pflag); - free(mflag); - return true; - } - mflag[-nums[i]] = 1; - } - else { - if (pflag[nums[i]] == 1) { - free(pflag); - free(mflag); - return true; - } - pflag[nums[i]] = 1; - } - } - free(pflag); - free(mflag); - return false; -} - -void main(void) { - int test[100001] = {0}; - printf("%d\n", containsDuplicate(test, 1)); -} From b213d93ce31a9c7e07b897d15008330c17a5646c Mon Sep 17 00:00:00 2001 From: csucom Date: Mon, 9 Dec 2024 09:55:01 +0900 Subject: [PATCH 16/17] contains-duplicate solution --- contains-duplicate/csucom.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contains-duplicate/csucom.cpp b/contains-duplicate/csucom.cpp index 61544a620..1fcb4171e 100644 --- a/contains-duplicate/csucom.cpp +++ b/contains-duplicate/csucom.cpp @@ -1,4 +1,4 @@ -#include +//#include #include #include @@ -30,7 +30,7 @@ bool containsDuplicate(int* nums, int numsSize) { return false; } -void main(void) { - int test[100001] = {0}; - printf("%d\n", containsDuplicate(test, 1)); -} +// void main(void) { +// int test[100001] = {0}; +// printf("%d\n", containsDuplicate(test, 1)); +// } From 49876ae2bb059a7241fc95430c5428c30bbeeb3f Mon Sep 17 00:00:00 2001 From: Sungwook Choi Date: Mon, 9 Dec 2024 23:43:55 +0900 Subject: [PATCH 17/17] contains-duplicate solution --- contains-duplicate/csucom.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/contains-duplicate/csucom.cpp b/contains-duplicate/csucom.cpp index 1fcb4171e..18057c2f1 100644 --- a/contains-duplicate/csucom.cpp +++ b/contains-duplicate/csucom.cpp @@ -1,4 +1,3 @@ -//#include #include #include @@ -30,7 +29,4 @@ bool containsDuplicate(int* nums, int numsSize) { return false; } -// void main(void) { -// int test[100001] = {0}; -// printf("%d\n", containsDuplicate(test, 1)); -// } +