From 609e3c717f773be1ca294812b5cf2bd86c6efca0 Mon Sep 17 00:00:00 2001 From: Robin Yoon Date: Mon, 2 Mar 2026 16:38:50 +0900 Subject: [PATCH 1/5] contains duplicate solution --- contains-duplicate/robinyoon-dev.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 contains-duplicate/robinyoon-dev.js diff --git a/contains-duplicate/robinyoon-dev.js b/contains-duplicate/robinyoon-dev.js new file mode 100644 index 0000000000..ab6044ea70 --- /dev/null +++ b/contains-duplicate/robinyoon-dev.js @@ -0,0 +1,17 @@ +/** + * @param {number[]} nums + * @return {boolean} + */ +var containsDuplicate = function(nums) { + let arrToSet = new Set(nums); + + const originalLength = nums.length; + const filteredLength = arrToSet.size; + + if(originalLength === filteredLength){ + return false; // 겹치는 숫자가 없는 경우 + } else { + return true; // 겹치는 숫자가 있는 경우 + } + +}; From 5534d22aa568d6919cea7e4e247a9f3d223fbaf9 Mon Sep 17 00:00:00 2001 From: Robin Yoon Date: Tue, 3 Mar 2026 15:00:01 +0900 Subject: [PATCH 2/5] two some solution --- two-sum/robinyoon-dev.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 two-sum/robinyoon-dev.js diff --git a/two-sum/robinyoon-dev.js b/two-sum/robinyoon-dev.js new file mode 100644 index 0000000000..a528c1d951 --- /dev/null +++ b/two-sum/robinyoon-dev.js @@ -0,0 +1,21 @@ +/** + * @param {number[]} nums + * @param {number} target + * @return {number[]} + */ +var twoSum = function (nums, target) { + for (let i = 0; i < nums.length; i++) { + let remaindedNum = target - nums[i]; + let matchedNum = nums.find((item) => remaindedNum === item); + let matchedNumIndex = nums.indexOf(matchedNum, i + 1); + // i와 matchedNumIndex 이 같은 숫자면 안 됨. + if (i === matchedNumIndex) { + continue; + } else if (matchedNumIndex === -1) { + continue; + } + else { + return [i, matchedNumIndex]; + } + } +}; From 527367f65f0bb05393d6421350782941daae3775 Mon Sep 17 00:00:00 2001 From: Robin Yoon Date: Wed, 4 Mar 2026 09:52:53 +0900 Subject: [PATCH 3/5] top k frequent elements solution --- top-k-frequent-elements/robinyoon-dev.js | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 top-k-frequent-elements/robinyoon-dev.js diff --git a/top-k-frequent-elements/robinyoon-dev.js b/top-k-frequent-elements/robinyoon-dev.js new file mode 100644 index 0000000000..429bea1452 --- /dev/null +++ b/top-k-frequent-elements/robinyoon-dev.js @@ -0,0 +1,33 @@ +/** + * @param {number[]} nums + * @param {number} k + * @return {number[]} + */ +var topKFrequent = function(nums, k) { + let numsMap = new Map(); + + for (let i = 0; i < nums.length; i++) { + // 1. numsMap에 nums[i]가 key로 있나 확인 + // 1-1. 있으면 nums[i]와 동일한 key를 찾은 후 value에 +1 + // 1-2. 없으면 새로 생성 & value를 1로. + let hasNum = numsMap.has(nums[i]); + if (hasNum) { + numsMap.set(nums[i], numsMap.get(nums[i]) + 1); + } else { + numsMap.set(nums[i], 1); + } + } + + // 2. numsMap을 배열로 변경 (mapToArr) + // 3. mapToArr에서 value가 가장 놓은 순대로 sort + // 4. mapToArr를 k개 까지만 잘라낸 후 + // 5. mapToArr의 각 아이템의 0번째 값만 추출하여 새로운 배열 만들고 return + let mapToArr = Array.from(numsMap); + + mapToArr.sort((a, b) => b[1] - a[1]); + + const slicedMapToArr = mapToArr.slice(0, k); + const result = slicedMapToArr.map((item) => item[0]); + + return result; +}; From e56df257228249da5775cd311f8685d972c1c28d Mon Sep 17 00:00:00 2001 From: Robin Yoon Date: Thu, 5 Mar 2026 22:47:37 +0900 Subject: [PATCH 4/5] longest consecutive sequence solution --- longest-consecutive-sequence/robinyoon-dev.js | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 longest-consecutive-sequence/robinyoon-dev.js diff --git a/longest-consecutive-sequence/robinyoon-dev.js b/longest-consecutive-sequence/robinyoon-dev.js new file mode 100644 index 0000000000..6055417f9b --- /dev/null +++ b/longest-consecutive-sequence/robinyoon-dev.js @@ -0,0 +1,38 @@ +/** + * @param {number[]} nums + * @return {number} + */ +var longestConsecutive = function (nums) { + + //엣지케이스: 빈배열인 경우 + if (nums.length === 0) { + return 0; + } + + //Set으로 중복값 제거하기 + const numsSet = new Set(nums); + + let tempMaxLength = 1; + + for (num of numsSet) { + let startPoint = num - 1; + let hasStart = numsSet.has(startPoint); + + //!hasStart인 num이 첫번째에 와야할 수니까! + if (!hasStart) { + + let currentLength = 1; + + while (numsSet.has(num + currentLength)) { + currentLength++; + } + // max 찾기 + tempMaxLength = Math.max(currentLength, tempMaxLength); + } else { + continue; + } + } + + return tempMaxLength; + +}; From 976cf2800d6f83a9753dc2c49310093d175349e4 Mon Sep 17 00:00:00 2001 From: Robin Yoon Date: Fri, 6 Mar 2026 16:12:33 +0900 Subject: [PATCH 5/5] house robber solution --- house-robber/robinyoon-dev.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 house-robber/robinyoon-dev.js diff --git a/house-robber/robinyoon-dev.js b/house-robber/robinyoon-dev.js new file mode 100644 index 0000000000..a39e60d1ad --- /dev/null +++ b/house-robber/robinyoon-dev.js @@ -0,0 +1,22 @@ +/** + * @param {number[]} nums + * @return {number} + */ +var rob = function (nums) { + + const NUMS_LENGTH = nums.length; + + if (NUMS_LENGTH === 0) return 0; + if (NUMS_LENGTH === 1) return nums[0]; + + const maxSumsArr = new Array(NUMS_LENGTH); + maxSumsArr[0] = nums[0]; + maxSumsArr[1] = Math.max(nums[0], nums[1]); + + for (let i = 2; i < NUMS_LENGTH; i++) { + maxSumsArr[i] = Math.max(maxSumsArr[i - 2] + nums[i], maxSumsArr[i - 1]); + } + + return maxSumsArr[NUMS_LENGTH - 1]; + +};