From 865ed8deb5198d5f8c8038db9754dfc4d5ae77f9 Mon Sep 17 00:00:00 2001 From: freemjstudio Date: Mon, 22 Jun 2026 01:07:05 +0900 Subject: [PATCH 1/5] freemjstudio/two-sum --- two-sum/freemjstudio.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 two-sum/freemjstudio.py diff --git a/two-sum/freemjstudio.py b/two-sum/freemjstudio.py new file mode 100644 index 0000000000..c36de0f08d --- /dev/null +++ b/two-sum/freemjstudio.py @@ -0,0 +1,13 @@ +class Solution: + def twoSum(self, nums: List[int], target: int) -> List[int]: + answer = [] + hashmap = dict() + for i in range(len(nums)): + current_num = nums[i] + diff = target - current_num + if diff in hashmap.keys(): + return [i, hashmap[diff]] + hashmap[current_num] = i # store the index of current num + + return answer + \ No newline at end of file From 1a6de375f2d596b02d7c08c3584c2e389f7a326a Mon Sep 17 00:00:00 2001 From: freemjstudio Date: Sat, 27 Jun 2026 16:38:18 +0900 Subject: [PATCH 2/5] freemjstudio: contains-duplicate (easy, python) --- contains-duplicate/freemjstudio.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 contains-duplicate/freemjstudio.py diff --git a/contains-duplicate/freemjstudio.py b/contains-duplicate/freemjstudio.py new file mode 100644 index 0000000000..bee8ade7ad --- /dev/null +++ b/contains-duplicate/freemjstudio.py @@ -0,0 +1,6 @@ +class Solution: + def containsDuplicate(self, nums: List[int]) -> bool: + first = len(nums) + set_nums = set(nums) + second = len(set_nums) + return (first != second) \ No newline at end of file From 953117650d0c3fc4c75ccd15503f14b75bc43cde Mon Sep 17 00:00:00 2001 From: freemjstudio Date: Sat, 27 Jun 2026 16:38:42 +0900 Subject: [PATCH 3/5] freemjstudio: contains-duplicate --- contains-duplicate/freemjstudio.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contains-duplicate/freemjstudio.py b/contains-duplicate/freemjstudio.py index bee8ade7ad..0273cbd4e3 100644 --- a/contains-duplicate/freemjstudio.py +++ b/contains-duplicate/freemjstudio.py @@ -1,6 +1,8 @@ class Solution: def containsDuplicate(self, nums: List[int]) -> bool: - first = len(nums) - set_nums = set(nums) + first = len(nums) # O(1) : 리스트 객체는 이미 자기자신의 길이를 저장하고 있음 + set_nums = set(nums) # O(N) second = len(set_nums) - return (first != second) \ No newline at end of file + return (first != second) + +# 시간 복잡도 : O(N) \ No newline at end of file From 370fe38dead4945f03001ca6800b1e397359f5fc Mon Sep 17 00:00:00 2001 From: freemjstudio Date: Sun, 28 Jun 2026 15:38:37 +0900 Subject: [PATCH 4/5] freemjstudio: top k frequent elements --- top-k-frequent-elements/freemjstudio.py | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 top-k-frequent-elements/freemjstudio.py diff --git a/top-k-frequent-elements/freemjstudio.py b/top-k-frequent-elements/freemjstudio.py new file mode 100644 index 0000000000..184c87aeee --- /dev/null +++ b/top-k-frequent-elements/freemjstudio.py @@ -0,0 +1,29 @@ +import heapq + +class Solution: + def topKFrequent(self, nums: List[int], k: int) -> List[int]: + answer = [] + count = dict() + heap = [] + if len(nums) <= 1: + return nums + # O(N) + for num in nums: + count[num] = count.get(num, 0) + 1 + + # heap 의 크기는 최대 k 로 제한함. + # unique 한 M개의 숫자를 선형 순회 O(M) + for num, freq in count.items(): + if len(heap) < k: + heapq.heappush(heap, (freq, num)) # O(logK) + else: + if heap[0][0] < freq: + heapq.heappop(heap) # O(logK) + heapq.heappush(heap, (freq, num)) # O(logK) + + for _ in range(k): + k, v = heapq.heappop(heap) + answer.append(v) + + return answer + From db69654f98e5b21d05356c77480071fcc2fc747c Mon Sep 17 00:00:00 2001 From: freemjstudio Date: Thu, 2 Jul 2026 00:42:35 +0900 Subject: [PATCH 5/5] =?UTF-8?q?liner=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contains-duplicate/freemjstudio.py | 2 +- two-sum/freemjstudio.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/contains-duplicate/freemjstudio.py b/contains-duplicate/freemjstudio.py index 0273cbd4e3..6048a3c5ea 100644 --- a/contains-duplicate/freemjstudio.py +++ b/contains-duplicate/freemjstudio.py @@ -5,4 +5,4 @@ def containsDuplicate(self, nums: List[int]) -> bool: second = len(set_nums) return (first != second) -# 시간 복잡도 : O(N) \ No newline at end of file +# 시간 복잡도 : O(N) diff --git a/two-sum/freemjstudio.py b/two-sum/freemjstudio.py index c36de0f08d..a274028f5c 100644 --- a/two-sum/freemjstudio.py +++ b/two-sum/freemjstudio.py @@ -10,4 +10,3 @@ def twoSum(self, nums: List[int], target: int) -> List[int]: hashmap[current_num] = i # store the index of current num return answer - \ No newline at end of file