From a0e762a4baab25cc4b3c8be0b1fb026ef2f9b650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=98=81?= Date: Mon, 2 Mar 2026 11:08:52 +0900 Subject: [PATCH 1/6] =?UTF-8?q?containsDuplicate=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contains-duplicate/junzero741.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 contains-duplicate/junzero741.ts diff --git a/contains-duplicate/junzero741.ts b/contains-duplicate/junzero741.ts new file mode 100644 index 0000000000..dfb889374c --- /dev/null +++ b/contains-duplicate/junzero741.ts @@ -0,0 +1,4 @@ +function containsDuplicate(nums: number[]): boolean { + const uniqueNums = new Set(nums); + return uniqueNums.size < nums.length +}; From 1b9b9706dba16e777a503672a35711f0dcfd295f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=98=81?= Date: Mon, 2 Mar 2026 11:26:03 +0900 Subject: [PATCH 2/6] =?UTF-8?q?containsDuplicate=20=EC=97=90=20TC,=20SC=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contains-duplicate/junzero741.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contains-duplicate/junzero741.ts b/contains-duplicate/junzero741.ts index dfb889374c..236282d899 100644 --- a/contains-duplicate/junzero741.ts +++ b/contains-duplicate/junzero741.ts @@ -1,3 +1,5 @@ +// TC: O(n) +// SC: O(n) function containsDuplicate(nums: number[]): boolean { const uniqueNums = new Set(nums); return uniqueNums.size < nums.length From 8b82af4708f6578cceefa4c5060a9f4ac0620927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=98=81?= Date: Mon, 2 Mar 2026 14:28:57 +0900 Subject: [PATCH 3/6] =?UTF-8?q?two-sum=20=EB=AC=B8=EC=A0=9C=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- two-sum/junzero741.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 two-sum/junzero741.ts diff --git a/two-sum/junzero741.ts b/two-sum/junzero741.ts new file mode 100644 index 0000000000..47ea03b580 --- /dev/null +++ b/two-sum/junzero741.ts @@ -0,0 +1,18 @@ +// TC: O(n) +// SC: O(n) +function twoSum(nums: number[], target: number): number[] { + const n = nums.length; + const complementMap = new Map(); + + for(let aIndex = 0; aIndex < n; aIndex++) { + const a = nums[aIndex]; + const b = target - a; + + if(complementMap.has(b)) { + return [complementMap.get(b) || -1, aIndex]; + } + complementMap.set(a, aIndex); + } + + return [-1, -1]; +}; From 00c625724784186873c0ce3d940733ba5c500159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=98=81?= Date: Mon, 2 Mar 2026 23:23:53 +0900 Subject: [PATCH 4/6] =?UTF-8?q?topKFrequent=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- top-k-frequent-elements/junzero741.ts | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 top-k-frequent-elements/junzero741.ts diff --git a/top-k-frequent-elements/junzero741.ts b/top-k-frequent-elements/junzero741.ts new file mode 100644 index 0000000000..3a949bc2b5 --- /dev/null +++ b/top-k-frequent-elements/junzero741.ts @@ -0,0 +1,37 @@ + +// TC: O(NlogN) +// SC: O(N) +function topKFrequent(nums: number[], k: number): number[] { + + /** + Map ( O(N) ) + 1 : 4 + 4 : 1 + 3 : 3 + 2 : 2 + + -> convert it to array ( O(N) ) : [[1,4], [4,1], [3,3], [2,2]] + -> sort by value ( O(NlogN) ): [[1,4], [3,3], [2,2], [4,1]] + -> slice(0,k) ( (O(N) ) : [[1,4], [3,3]] + -> make array from keys ( (O(N) ) : [1,4] + */ + + const numMap = new Map(); + const n = nums.length; + + for(let i = 0; i < n; i++) { + const num = nums[i]; + const frequency = (numMap.get(num) || 0) + numMap.set(num, frequency + 1); + } + + + const numFrequencyArr = Array.from(numMap); + const sortedNumFrequencyKeysArr = + numFrequencyArr + .sort((a,b) => b[1]-a[1]) + .map((entry) => entry[0]); + + + return sortedNumFrequencyKeysArr.slice(0, k) +}; From fd1299d2e118bca7abd8d3abe16b539353bf3f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=98=81?= Date: Tue, 3 Mar 2026 16:10:14 +0900 Subject: [PATCH 5/6] =?UTF-8?q?longest-consecutive-sequence=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- longest-consecutive-sequence/junzero741.ts | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 longest-consecutive-sequence/junzero741.ts diff --git a/longest-consecutive-sequence/junzero741.ts b/longest-consecutive-sequence/junzero741.ts new file mode 100644 index 0000000000..58f4a0af63 --- /dev/null +++ b/longest-consecutive-sequence/junzero741.ts @@ -0,0 +1,23 @@ +// TC: O(N) +// SC: O(N) +function longestConsecutive(nums: number[]): number { + let finalMaxSequence = 0; + + // O(n) + const numsSet = new Set(nums); + + // O(n) + for(const num of numsSet) { + if(numsSet.has(num - 1)) { + continue; + } + let currentMaxSequence = 1; + while(numsSet.has(num + currentMaxSequence)) { + currentMaxSequence++; + } + finalMaxSequence = Math.max(finalMaxSequence, currentMaxSequence); + } + + return finalMaxSequence; + +}; \ No newline at end of file From da16ab29810a4339c128faa0f70eb6a733cda070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=98=81?= Date: Tue, 3 Mar 2026 16:11:24 +0900 Subject: [PATCH 6/6] =?UTF-8?q?longest-consecutive-sequence=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4=20end=20line=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- longest-consecutive-sequence/junzero741.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/longest-consecutive-sequence/junzero741.ts b/longest-consecutive-sequence/junzero741.ts index 58f4a0af63..2e4cf8d358 100644 --- a/longest-consecutive-sequence/junzero741.ts +++ b/longest-consecutive-sequence/junzero741.ts @@ -20,4 +20,4 @@ function longestConsecutive(nums: number[]): number { return finalMaxSequence; -}; \ No newline at end of file +};