From b6e35e7b3443d60e415e1f8725dc12e6f45986e6 Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Fri, 26 Jun 2026 01:17:37 +0100 Subject: [PATCH 01/10] Implement containsDuplicate method in Solution class --- contains-duplicate/Chanz82.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 contains-duplicate/Chanz82.py diff --git a/contains-duplicate/Chanz82.py b/contains-duplicate/Chanz82.py new file mode 100644 index 0000000000..55fcc66236 --- /dev/null +++ b/contains-duplicate/Chanz82.py @@ -0,0 +1,10 @@ +class Solution: + def containsDuplicate(self, nums: List[int]) -> bool: + hashmap = dict() + sorted(nums) + for num in nums: + if hashmap.get(num, False) == True: + return True + else : + hashmap[num] = True + return False From e026ddde21f265c9f0363031e4a15bb5cb22c41f Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Fri, 26 Jun 2026 23:29:01 +0100 Subject: [PATCH 02/10] Add twoSum method in Solution class Implement twoSum method to find indices of two numbers that add up to target. --- two-sum/Chanz.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 two-sum/Chanz.py diff --git a/two-sum/Chanz.py b/two-sum/Chanz.py new file mode 100644 index 0000000000..5c41451095 --- /dev/null +++ b/two-sum/Chanz.py @@ -0,0 +1,20 @@ +class Solution: + def twoSum(self, nums: List[int], target: int) -> List[int]: + + ## 공간 복잡도 : O(n) + ## - n 개수 만큼의 hashmap 공간만을 사용하므로 공간복잡도가 O(n)이라고 생각합니다. + + ## 시간 복잡도 : O(n) + ## - hashmap에 값과 idx를 매칭하는 작업을 n번 수행합니다. + ## - 이후 다시 nums를 순회하면서 target이 되는 짝을 찾습니다. + ## - 따라서 Worst N번 이므로, 2n = O(n)이라고 생각합니다. + + hashmap = dict() + for idx, num in enumerate(nums): + hashmap[num] = idx + + for idx, num in enumerate(nums): + matched_num_idx = hashmap.get(target-num) + if matched_num_idx and matched_num_idx != idx: + return [idx, matched_num_idx] + From e8339c9b9f962f89ab0459ec6ebdefd96a474e2b Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Fri, 26 Jun 2026 23:30:47 +0100 Subject: [PATCH 03/10] Rename Chanz.py to Chanz82.py --- two-sum/{Chanz.py => Chanz82.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename two-sum/{Chanz.py => Chanz82.py} (100%) diff --git a/two-sum/Chanz.py b/two-sum/Chanz82.py similarity index 100% rename from two-sum/Chanz.py rename to two-sum/Chanz82.py From 40cb681a27a3b615df351f65a89f2f2e0c58840e Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Fri, 26 Jun 2026 23:46:22 +0100 Subject: [PATCH 04/10] Optimize two-sum algorithm with single loop Refactor two-sum solution to use a single loop for finding matches. --- two-sum/Chanz82.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/two-sum/Chanz82.py b/two-sum/Chanz82.py index 5c41451095..55ef11f80e 100644 --- a/two-sum/Chanz82.py +++ b/two-sum/Chanz82.py @@ -10,11 +10,11 @@ def twoSum(self, nums: List[int], target: int) -> List[int]: ## - 따라서 Worst N번 이므로, 2n = O(n)이라고 생각합니다. hashmap = dict() + for idx, num in enumerate(nums): - hashmap[num] = idx - - for idx, num in enumerate(nums): - matched_num_idx = hashmap.get(target-num) - if matched_num_idx and matched_num_idx != idx: - return [idx, matched_num_idx] + possible_match = target - num + if possible_match in hashmap: + return [idx, hashmap[possible_match]] + else: + hashmap[num] = idx From 5564f3d7d46247dd999ca47f953816f479d8a885 Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:09:52 +0100 Subject: [PATCH 05/10] Add isAnagram method to Solution class Implement isAnagram method to check if two strings are anagrams using a hashmap. --- valid-anagram/Chanz.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 valid-anagram/Chanz.py diff --git a/valid-anagram/Chanz.py b/valid-anagram/Chanz.py new file mode 100644 index 0000000000..af5f63c81f --- /dev/null +++ b/valid-anagram/Chanz.py @@ -0,0 +1,19 @@ +class Solution: + def isAnagram(self, s: str, t: str) -> bool: + hashmap = dict() + + # 공간복잡도 : hashmap을 사용하므로 공간복잡도는 O(N)입니다. + # 시간복잡도 : 문자열 s의 길이만큼 한번 순회하고, 다시 문자열 t의 길이만큼 순회하므로 O(s+t) => O(N)입니다. + for ch in s: + hashmap[ch] = hashmap.get(ch, 0) + 1 + + for ch in t: + if ch in hashmap: + hashmap[ch] -= 1 + if hashmap[ch] == 0: + del hashmap[ch] + else: + return False + + return not hashmap + From bad1013c915aed1bf51c76b3273e1a4e53554e05 Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:10:52 +0100 Subject: [PATCH 06/10] Add Solution class for climbing stairs with memoization Implement memoization for climbing stairs problem. --- climbing-stairs/Chanz.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 climbing-stairs/Chanz.py diff --git a/climbing-stairs/Chanz.py b/climbing-stairs/Chanz.py new file mode 100644 index 0000000000..b82ed88989 --- /dev/null +++ b/climbing-stairs/Chanz.py @@ -0,0 +1,23 @@ +class Solution: + + def __init__(self): + self.memo = dict() + + def climbStairs(self, n: int) -> int: + + # 공간복잡도 : n의 개수 만큼 memo가 할당되므로 o(n) + # 시간복잡도 : 각 칸에 대해서 계산이 1번씩만 되므로 o(n) + + # base + if n <= 2 : + return n + + # 이미 계산 한 값이라면 반환 + if n in self.memo: + return self.memo[n] + + # 1칸 전과 2칸 전의 결과를 합한 것을 반환. + result = self.climbStairs(n-2) + self.climbStairs(n-1) + self.memo[n] = result + + return result From 913950b3fff5b3eb896255ab2f903b5414e4d1ea Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:11:37 +0100 Subject: [PATCH 07/10] Add productExceptSelf method in Solution class Implement productExceptSelf method to calculate the product of array except self using two auxiliary lists. --- product-of-array-except-self/Chanz.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 product-of-array-except-self/Chanz.py diff --git a/product-of-array-except-self/Chanz.py b/product-of-array-except-self/Chanz.py new file mode 100644 index 0000000000..ff54ece5bc --- /dev/null +++ b/product-of-array-except-self/Chanz.py @@ -0,0 +1,16 @@ +class Solution: + def productExceptSelf(self, nums: List[int]) -> List[int]: + + # 공간 복잡도 : 2개의 list를 사용하므로 O(2n)=O(n) + # 시간 복잡도 : nums를 세번 순회 o(n) + n = len(nums) + left = [1] * n + right = [1] * n + + for idx in range(1, n): + left[idx] = left[idx-1] * nums[idx-1] + + for idx in range(n-2, -1, -1): + right[idx] = right[idx+1] * nums[idx+1] + + return [left[i] * right[i] for i in range(n)] From f23e05ee98976a3e964c10f24b6d3ec9eb088a13 Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:22:33 +0100 Subject: [PATCH 08/10] Rename Chanz.py to Chanz82.py --- valid-anagram/{Chanz.py => Chanz82.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename valid-anagram/{Chanz.py => Chanz82.py} (100%) diff --git a/valid-anagram/Chanz.py b/valid-anagram/Chanz82.py similarity index 100% rename from valid-anagram/Chanz.py rename to valid-anagram/Chanz82.py From 9fdd08fc6529902528e77b65f47341f2727e2868 Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:23:04 +0100 Subject: [PATCH 09/10] Rename Chanz.py to Chanz82.py --- product-of-array-except-self/{Chanz.py => Chanz82.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename product-of-array-except-self/{Chanz.py => Chanz82.py} (100%) diff --git a/product-of-array-except-self/Chanz.py b/product-of-array-except-self/Chanz82.py similarity index 100% rename from product-of-array-except-self/Chanz.py rename to product-of-array-except-self/Chanz82.py From 85e32b985f63facb37dcf77100ba14c124ae00df Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:23:21 +0100 Subject: [PATCH 10/10] Add new climbing stairs solution in Chanz82.py --- climbing-stairs/{Chanz.py => Chanz82.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename climbing-stairs/{Chanz.py => Chanz82.py} (100%) diff --git a/climbing-stairs/Chanz.py b/climbing-stairs/Chanz82.py similarity index 100% rename from climbing-stairs/Chanz.py rename to climbing-stairs/Chanz82.py