From 9d9d3b9c3f50fb4bdafeb2b5a754fe55f4869ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=B8=EC=A7=84?= <50974359+hozzijeong@users.noreply.github.com> Date: Mon, 10 Nov 2025 23:52:16 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20contain-duplicate=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contains-duplicate/hozzijeong.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 contains-duplicate/hozzijeong.js diff --git a/contains-duplicate/hozzijeong.js b/contains-duplicate/hozzijeong.js new file mode 100644 index 0000000000..47da62bf1d --- /dev/null +++ b/contains-duplicate/hozzijeong.js @@ -0,0 +1,10 @@ +/** + * @param {number[]} nums + * @return {boolean} + */ +var containsDuplicate = function(nums) { + const originLength = nums.length; + const numsSet = new Set(nums); + + return originLength !== numsSet.size; +}; From f4e21bcd9069c91a761738840b223d091c692dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=B8=EC=A7=84?= <50974359+hozzijeong@users.noreply.github.com> Date: Sat, 15 Nov 2025 21:45:01 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20two-sum=20=ED=92=80=EC=9D=B4=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- two-sum/hozzijeong.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 two-sum/hozzijeong.js diff --git a/two-sum/hozzijeong.js b/two-sum/hozzijeong.js new file mode 100644 index 0000000000..5b9178e07e --- /dev/null +++ b/two-sum/hozzijeong.js @@ -0,0 +1,17 @@ +/** + * @param {number[]} nums + * @param {number} target + * @return {number[]} + */ +var twoSum = function(nums, target) { + for(let i =0; i < nums.length - 1; i++){ + const first = nums[i]; + for(let j = i + 1; j < nums.length; j++){ + const last = nums[j]; + + if((first + last) === target) return [i,j] + } + } + + return [] +}; From f29764f7e2ab859dd634e9431f355928db0a4cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=B8=EC=A7=84?= <50974359+hozzijeong@users.noreply.github.com> Date: Sat, 15 Nov 2025 21:51:57 +0900 Subject: [PATCH 3/4] feat: top-k-frequent-elements --- top-k-frequent-elements/hozzijeong.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 top-k-frequent-elements/hozzijeong.js diff --git a/top-k-frequent-elements/hozzijeong.js b/top-k-frequent-elements/hozzijeong.js new file mode 100644 index 0000000000..cd1e51866d --- /dev/null +++ b/top-k-frequent-elements/hozzijeong.js @@ -0,0 +1,25 @@ +/** + * @param {number[]} nums + * @param {number} k + * @return {number[]} + */ +var topKFrequent = function(nums, k) { + const numsMap = new Map(); + + for(const num of nums){ + const currentNums = numsMap.get(num); + + if(!currentNums){ + numsMap.set(num, 1); + continue; + } + + numsMap.set(num, currentNums + 1) + } + + const sortedNums = [...numsMap].sort((a,b) => b[1] - a[1]); + + const frequencyNums = sortedNums.map(([num])=> num); + + return frequencyNums.slice(0,k); +}; From 8a17b6540111405f0d0fe1de00138113d4c21770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=B8=EC=A7=84?= <50974359+hozzijeong@users.noreply.github.com> Date: Sat, 15 Nov 2025 22:20:30 +0900 Subject: [PATCH 4/4] feat: longest-consecutive-sequence --- longest-consecutive-sequence/hozzijeong.js | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 longest-consecutive-sequence/hozzijeong.js diff --git a/longest-consecutive-sequence/hozzijeong.js b/longest-consecutive-sequence/hozzijeong.js new file mode 100644 index 0000000000..9f7c468a62 --- /dev/null +++ b/longest-consecutive-sequence/hozzijeong.js @@ -0,0 +1,33 @@ +/** + * @param {number[]} nums + * @return {number} + */ +var longestConsecutive = function(nums) { + const numsSet = new Set(nums); + + + if(nums.length === 0) return 0 + + const sortedNums = [...numsSet].sort((a,b) => a-b); + + const results = []; + + let result = 1; + + for(let i = 0; i < sortedNums.length-1; i++){ + const current = sortedNums[i]; + const next = sortedNums[i+1]; + + if((current + 1) === next){ + result += 1; + }else{ + results.push(result); + result = 1; + } + } + + results.push(result); + + + return Math.max(...results) +};