From 89ab5af689aecd04367574a5d372f04cde432b62 Mon Sep 17 00:00:00 2001 From: leehyeyun Date: Fri, 14 Nov 2025 10:33:29 +0900 Subject: [PATCH 1/5] contains duplicate solution --- contains-duplicate/leehyeyun.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 contains-duplicate/leehyeyun.js diff --git a/contains-duplicate/leehyeyun.js b/contains-duplicate/leehyeyun.js new file mode 100644 index 0000000000..1de8b8d8c5 --- /dev/null +++ b/contains-duplicate/leehyeyun.js @@ -0,0 +1,31 @@ +/** + * @param {number[]} nums + * @return {boolean} + */ + +/* + nums 배열이 주어졌을 때, + 중복된 값이 존재하면 true, + 중복된 값이 없으면 false를 반환하는 함수 + + 요청형식 : containsDuplicate(nums) + 입력형식 : nums는 정수 배열로 길이는 1 이상 10^5 이하, 각 원소는 -10^9 이상 10^9 이하 + + 요청예시 : containsDuplicate([1,2,3,1]) + 출력예시 : true +*/ +var containsDuplicate = function(nums) { + + const set = new Set(nums); + + if(nums.length != set.size){ + return true; + }else { + return false; + } +}; + +// 테스트 실행 +console.log("Example 1:", containsDuplicate([1, 2, 3, 1])); // true +console.log("Example 2:", containsDuplicate([1, 2, 3, 4])); // false +console.log("Example 3:", containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2])); // true \ No newline at end of file From b2a614b4be915fbacda40dbc6ab7589289d2712b Mon Sep 17 00:00:00 2001 From: leehyeyun Date: Fri, 14 Nov 2025 10:58:23 +0900 Subject: [PATCH 2/5] contains duplicate solution --- contains-duplicate/leehyeyun.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contains-duplicate/leehyeyun.js b/contains-duplicate/leehyeyun.js index 1de8b8d8c5..36118da8e4 100644 --- a/contains-duplicate/leehyeyun.js +++ b/contains-duplicate/leehyeyun.js @@ -28,4 +28,4 @@ var containsDuplicate = function(nums) { // 테스트 실행 console.log("Example 1:", containsDuplicate([1, 2, 3, 1])); // true console.log("Example 2:", containsDuplicate([1, 2, 3, 4])); // false -console.log("Example 3:", containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2])); // true \ No newline at end of file +console.log("Example 3:", containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2])); // true From 53c4022027f4a7046ba073ae425f956889460595 Mon Sep 17 00:00:00 2001 From: leehyeyun Date: Fri, 14 Nov 2025 14:27:30 +0900 Subject: [PATCH 3/5] two sum solution --- two-sum/leehyeyun.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 two-sum/leehyeyun.js diff --git a/two-sum/leehyeyun.js b/two-sum/leehyeyun.js new file mode 100644 index 0000000000..87320683c1 --- /dev/null +++ b/two-sum/leehyeyun.js @@ -0,0 +1,37 @@ +/** + * @param {number[]} nums + * @param {number} target + * @return {number[]} + */ + +/* + 정수 배열 nums와 목표값 target이 주어졌을 때, + 두 수를 더해 target이 되는 인덱스를 반환하는 함수 + + 요청형식 : twoSum(nums, target) + 입력형식 : nums는 정수 배열, target은 정수 + 출력형식 : target을 만족하는 두 수의 인덱스를 [i, j] 형태로 반환 + + 요청예시 : twoSum([2,7,11,15], 9) + 출력예시 : [0, 1] +*/ +var twoSum = function(nums, target) { + + const map = new Map(); + + for (let i=0; i Date: Fri, 14 Nov 2025 17:38:31 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=EA=B0=9C=ED=96=89=EB=AC=B8=EC=9E=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contains-duplicate/leehyeyun.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contains-duplicate/leehyeyun.js b/contains-duplicate/leehyeyun.js index 36118da8e4..a6d7d4b7ad 100644 --- a/contains-duplicate/leehyeyun.js +++ b/contains-duplicate/leehyeyun.js @@ -28,4 +28,5 @@ var containsDuplicate = function(nums) { // 테스트 실행 console.log("Example 1:", containsDuplicate([1, 2, 3, 1])); // true console.log("Example 2:", containsDuplicate([1, 2, 3, 4])); // false -console.log("Example 3:", containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2])); // true +console.log("Example 3:", containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2])); // true + From 65495fc9216835f97e89c62efcb326af30a2fd99 Mon Sep 17 00:00:00 2001 From: leehyeyun Date: Fri, 14 Nov 2025 17:39:12 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=EA=B0=9C=ED=96=89=EB=AC=B8=EC=9E=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- two-sum/leehyeyun.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/two-sum/leehyeyun.js b/two-sum/leehyeyun.js index 87320683c1..f3be15a474 100644 --- a/two-sum/leehyeyun.js +++ b/two-sum/leehyeyun.js @@ -34,4 +34,5 @@ var twoSum = function(nums, target) { console.log(twoSum([2,7,11,15], 9)); console.log(twoSum([3,2,4], 6)); -console.log(twoSum([3,3], 6)); +console.log(twoSum([3,3], 6)); +