From 3229beaad1a5bdfea712c64f9c8915ee817a1c09 Mon Sep 17 00:00:00 2001 From: HYUNAHKO Date: Thu, 27 Nov 2025 11:42:18 +0900 Subject: [PATCH 01/12] Week02 Solutions --- climbing-stairs/HYUNAHKO.py | 27 ++++++++++++++++ product-of-array-except-self/HYUNAHKO.py | 40 ++++++++++++++++++++++++ valid-anagram/HYUNAHKO.py | 25 +++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 climbing-stairs/HYUNAHKO.py create mode 100644 product-of-array-except-self/HYUNAHKO.py create mode 100644 valid-anagram/HYUNAHKO.py diff --git a/climbing-stairs/HYUNAHKO.py b/climbing-stairs/HYUNAHKO.py new file mode 100644 index 0000000000..79c1179f14 --- /dev/null +++ b/climbing-stairs/HYUNAHKO.py @@ -0,0 +1,27 @@ +class Solution: + def climbStairs(self, n: int) -> int: + if (n<1 or n>45): + return 0 + + def factorial(num): + if num <= 1: + return 1 + + result = 1 + for i in range(2, num+1): + result *= i + return result + + steps = 0 + cur_steps = 1 + quotient = n // 2 + k=0 + + for _ in range(quotient+1): + cur_steps = factorial(n-k) / (factorial(k)*factorial(n-2*k)) + k+=1 + steps += cur_steps + + return int(steps) + + diff --git a/product-of-array-except-self/HYUNAHKO.py b/product-of-array-except-self/HYUNAHKO.py new file mode 100644 index 0000000000..55498d54e5 --- /dev/null +++ b/product-of-array-except-self/HYUNAHKO.py @@ -0,0 +1,40 @@ +class Solution: + def productExceptSelf(self, nums: List[int]) -> List[int]: + n = len(nums) + result_list = [0] * n + if len(nums) <2 or len(nums) > 1e5: + return None + + p = 1 + for i in range(n): + result_list[i] = p + p *= nums[i] + + p = 1 + for i in range(n - 1, -1, -1): + result_list[i] *= p + p *= nums[i] + + return result_list + + + +class Solution: + def productExceptSelf(self, nums: List[int]) -> List[int]: + result_list = [0] * len(nums) + if len(nums) <2 or len(nums) > 1e5: + return None + + for idx in range(0, len(nums)): + result = 1 + for idx_left in range(0, idx): + result *= nums[idx_left] + + for idx_right in range(idx+1, len(nums)): + result *= nums[idx_right] + + result_list[idx] = result + + + return result_list + \ No newline at end of file diff --git a/valid-anagram/HYUNAHKO.py b/valid-anagram/HYUNAHKO.py new file mode 100644 index 0000000000..80b0fcb424 --- /dev/null +++ b/valid-anagram/HYUNAHKO.py @@ -0,0 +1,25 @@ +from collections import Counter + +class Solution: + def isAnagram(self, s: str, t: str) -> bool: + letter_dict1 = {} + letter_dict2 = {} + letter_list1 = list(s) + letter_list2 = list(t) + + for i in letter_list1: + letter_dict1[i] = letter_dict1.get(i, 0) + 1 + + for j in letter_list2: + letter_dict2[j] = letter_dict2.get(j, 0) + 1 + + if (letter_dict1 == letter_dict2): + return True + else: + return False + + +class Solution: + def isAnagram(self, s: str, t: str) -> bool: + return Counter(s) == Counter(t) + From 38d4c3cc771f14c8a73f85cafe301a09cbe39071 Mon Sep 17 00:00:00 2001 From: HYUNAHKO Date: Thu, 27 Nov 2025 23:16:30 +0900 Subject: [PATCH 02/12] Week 03 soultions --- combination-sum/HYUNAHKO.py' | 25 ++++++++++++++++++++++++ number-of-1-bits/HYUNAHKO.py | 10 ++++++++++ product-of-array-except-self/HYUNAHKO.py | 1 + valid-palindrome/HYUNAHKO.py | 12 ++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 combination-sum/HYUNAHKO.py' create mode 100644 number-of-1-bits/HYUNAHKO.py create mode 100644 valid-palindrome/HYUNAHKO.py diff --git a/combination-sum/HYUNAHKO.py' b/combination-sum/HYUNAHKO.py' new file mode 100644 index 0000000000..78fcbf6abb --- /dev/null +++ b/combination-sum/HYUNAHKO.py' @@ -0,0 +1,25 @@ +class Solution: + def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: + result = [] + + def backtrack(start_idx, current_combination, current_sum): + if current_sum == target: + result.append(current_combination[:]) + return + if current_sum > target: + return + + # 모든 후보 탐색 + for i in range(start_idx, len(candidates)): + # 현재 숫자 선택 + current_combination.append(candidates[i]) + + # 같은 숫자를 다시 사용할 수 있으므로 i부터 시작 + backtrack(i, current_combination, current_sum + candidates[i]) + + # 백트래킹 + current_combination.pop() + + backtrack(0, [], 0) + return result + \ No newline at end of file diff --git a/number-of-1-bits/HYUNAHKO.py b/number-of-1-bits/HYUNAHKO.py new file mode 100644 index 0000000000..f1fee52d71 --- /dev/null +++ b/number-of-1-bits/HYUNAHKO.py @@ -0,0 +1,10 @@ +class Solution: + def hammingWeight(self, n: int) -> int: + result = 1 + while (n//2 != 0): + remainder = n % 2 + if (remainder==1): + result+=1 + n = n//2 + return result + \ No newline at end of file diff --git a/product-of-array-except-self/HYUNAHKO.py b/product-of-array-except-self/HYUNAHKO.py index 55498d54e5..6b661fc6b5 100644 --- a/product-of-array-except-self/HYUNAHKO.py +++ b/product-of-array-except-self/HYUNAHKO.py @@ -37,4 +37,5 @@ def productExceptSelf(self, nums: List[int]) -> List[int]: return result_list + \ No newline at end of file diff --git a/valid-palindrome/HYUNAHKO.py b/valid-palindrome/HYUNAHKO.py new file mode 100644 index 0000000000..2baf8d8077 --- /dev/null +++ b/valid-palindrome/HYUNAHKO.py @@ -0,0 +1,12 @@ +class Solution: + def isPalindrome(self, s: str) -> bool: + s = s.lower() + result = [char for char in s if char.isalnum()] + + n = len(result) + for i in range(n): + str1 = result[i] + if (str1 != result[n-i-1]): + return False + return True + \ No newline at end of file From d5ccec9c801a84966d513753b1c293a29268c27e Mon Sep 17 00:00:00 2001 From: HYUNAHKO Date: Thu, 27 Nov 2025 23:18:06 +0900 Subject: [PATCH 03/12] end enter line --- combination-sum/HYUNAHKO.py' | 1 + 1 file changed, 1 insertion(+) diff --git a/combination-sum/HYUNAHKO.py' b/combination-sum/HYUNAHKO.py' index 78fcbf6abb..e35fae2867 100644 --- a/combination-sum/HYUNAHKO.py' +++ b/combination-sum/HYUNAHKO.py' @@ -22,4 +22,5 @@ class Solution: backtrack(0, [], 0) return result + \ No newline at end of file From c6719d107ed773f783d34a0a037df678d87bee51 Mon Sep 17 00:00:00 2001 From: HYUNAHKO Date: Thu, 27 Nov 2025 23:21:58 +0900 Subject: [PATCH 04/12] end enter line --- combination-sum/{HYUNAHKO.py' => HYUNAHKO.py} | 1 - 1 file changed, 1 deletion(-) rename combination-sum/{HYUNAHKO.py' => HYUNAHKO.py} (99%) diff --git a/combination-sum/HYUNAHKO.py' b/combination-sum/HYUNAHKO.py similarity index 99% rename from combination-sum/HYUNAHKO.py' rename to combination-sum/HYUNAHKO.py index e35fae2867..41b7777c8c 100644 --- a/combination-sum/HYUNAHKO.py' +++ b/combination-sum/HYUNAHKO.py @@ -23,4 +23,3 @@ def backtrack(start_idx, current_combination, current_sum): backtrack(0, [], 0) return result - \ No newline at end of file From c3bc51bc70e59d1a8575e88e0c333b8506ebbc31 Mon Sep 17 00:00:00 2001 From: HYUNAHKO Date: Fri, 28 Nov 2025 15:29:28 +0900 Subject: [PATCH 05/12] WEEK 03 Soultions --- valid-palindrome/HYUNAHKO.py | 1 + 1 file changed, 1 insertion(+) diff --git a/valid-palindrome/HYUNAHKO.py b/valid-palindrome/HYUNAHKO.py index 2baf8d8077..3fad49119a 100644 --- a/valid-palindrome/HYUNAHKO.py +++ b/valid-palindrome/HYUNAHKO.py @@ -9,4 +9,5 @@ def isPalindrome(self, s: str) -> bool: if (str1 != result[n-i-1]): return False return True + \ No newline at end of file From ee42edce0ff43b54e37c45cf1f1d5c3ef97f0973 Mon Sep 17 00:00:00 2001 From: HYUNAHKO Date: Fri, 28 Nov 2025 15:32:57 +0900 Subject: [PATCH 06/12] Enter end line --- number-of-1-bits/HYUNAHKO.py | 2 +- product-of-array-except-self/HYUNAHKO.py | 22 ---------------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/number-of-1-bits/HYUNAHKO.py b/number-of-1-bits/HYUNAHKO.py index f1fee52d71..bf914bb0cd 100644 --- a/number-of-1-bits/HYUNAHKO.py +++ b/number-of-1-bits/HYUNAHKO.py @@ -7,4 +7,4 @@ def hammingWeight(self, n: int) -> int: result+=1 n = n//2 return result - \ No newline at end of file + diff --git a/product-of-array-except-self/HYUNAHKO.py b/product-of-array-except-self/HYUNAHKO.py index 6b661fc6b5..3509a318a0 100644 --- a/product-of-array-except-self/HYUNAHKO.py +++ b/product-of-array-except-self/HYUNAHKO.py @@ -17,25 +17,3 @@ def productExceptSelf(self, nums: List[int]) -> List[int]: return result_list - - -class Solution: - def productExceptSelf(self, nums: List[int]) -> List[int]: - result_list = [0] * len(nums) - if len(nums) <2 or len(nums) > 1e5: - return None - - for idx in range(0, len(nums)): - result = 1 - for idx_left in range(0, idx): - result *= nums[idx_left] - - for idx_right in range(idx+1, len(nums)): - result *= nums[idx_right] - - result_list[idx] = result - - - return result_list - - \ No newline at end of file From 12573075aa35a2c8d1d4cd13d01588441aa04589 Mon Sep 17 00:00:00 2001 From: HYUNAHKO <126374997+HYUNAHKO@users.noreply.github.com> Date: Sat, 29 Nov 2025 09:58:45 +0900 Subject: [PATCH 07/12] Update number-of-1-bits/HYUNAHKO.py Co-authored-by: yhkee0404 --- number-of-1-bits/HYUNAHKO.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/number-of-1-bits/HYUNAHKO.py b/number-of-1-bits/HYUNAHKO.py index f1fee52d71..8fb258e54c 100644 --- a/number-of-1-bits/HYUNAHKO.py +++ b/number-of-1-bits/HYUNAHKO.py @@ -6,5 +6,4 @@ def hammingWeight(self, n: int) -> int: if (remainder==1): result+=1 n = n//2 - return result - \ No newline at end of file + return result \ No newline at end of file From f7bc00e595b6a715efd39ea41ed9beed69bf2536 Mon Sep 17 00:00:00 2001 From: HYUNAHKO <126374997+HYUNAHKO@users.noreply.github.com> Date: Sat, 29 Nov 2025 09:58:55 +0900 Subject: [PATCH 08/12] Update valid-palindrome/HYUNAHKO.py Co-authored-by: yhkee0404 --- valid-palindrome/HYUNAHKO.py | 1 - 1 file changed, 1 deletion(-) diff --git a/valid-palindrome/HYUNAHKO.py b/valid-palindrome/HYUNAHKO.py index 3fad49119a..2baf8d8077 100644 --- a/valid-palindrome/HYUNAHKO.py +++ b/valid-palindrome/HYUNAHKO.py @@ -9,5 +9,4 @@ def isPalindrome(self, s: str) -> bool: if (str1 != result[n-i-1]): return False return True - \ No newline at end of file From 0f7addd88b52aecd35a52b0c9ca3e60205670e1c Mon Sep 17 00:00:00 2001 From: HYUNAHKO Date: Sat, 29 Nov 2025 10:23:11 +0900 Subject: [PATCH 09/12] Final Revisions --- combination-sum/HYUNAHKO.py | 1 - number-of-1-bits/HYUNAHKO.py | 1 - product-of-array-except-self/HYUNAHKO.py | 21 +++++++++++++++++++++ valid-palindrome/HYUNAHKO.py | 1 - 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/combination-sum/HYUNAHKO.py b/combination-sum/HYUNAHKO.py index 41b7777c8c..30ce08144e 100644 --- a/combination-sum/HYUNAHKO.py +++ b/combination-sum/HYUNAHKO.py @@ -22,4 +22,3 @@ def backtrack(start_idx, current_combination, current_sum): backtrack(0, [], 0) return result - diff --git a/number-of-1-bits/HYUNAHKO.py b/number-of-1-bits/HYUNAHKO.py index bf914bb0cd..1d41c31f8d 100644 --- a/number-of-1-bits/HYUNAHKO.py +++ b/number-of-1-bits/HYUNAHKO.py @@ -7,4 +7,3 @@ def hammingWeight(self, n: int) -> int: result+=1 n = n//2 return result - diff --git a/product-of-array-except-self/HYUNAHKO.py b/product-of-array-except-self/HYUNAHKO.py index 3509a318a0..55498d54e5 100644 --- a/product-of-array-except-self/HYUNAHKO.py +++ b/product-of-array-except-self/HYUNAHKO.py @@ -17,3 +17,24 @@ def productExceptSelf(self, nums: List[int]) -> List[int]: return result_list + + +class Solution: + def productExceptSelf(self, nums: List[int]) -> List[int]: + result_list = [0] * len(nums) + if len(nums) <2 or len(nums) > 1e5: + return None + + for idx in range(0, len(nums)): + result = 1 + for idx_left in range(0, idx): + result *= nums[idx_left] + + for idx_right in range(idx+1, len(nums)): + result *= nums[idx_right] + + result_list[idx] = result + + + return result_list + \ No newline at end of file diff --git a/valid-palindrome/HYUNAHKO.py b/valid-palindrome/HYUNAHKO.py index 3fad49119a..2baf8d8077 100644 --- a/valid-palindrome/HYUNAHKO.py +++ b/valid-palindrome/HYUNAHKO.py @@ -9,5 +9,4 @@ def isPalindrome(self, s: str) -> bool: if (str1 != result[n-i-1]): return False return True - \ No newline at end of file From 0e1c3eb770b0d0ebaf3bc49f8c4e5457f1472117 Mon Sep 17 00:00:00 2001 From: HYUNAHKO Date: Sat, 29 Nov 2025 10:27:18 +0900 Subject: [PATCH 10/12] Final resolve merge conflict --- product-of-array-except-self/HYUNAHKO.py | 21 --------------------- valid-palindrome/HYUNAHKO.py | 1 - 2 files changed, 22 deletions(-) diff --git a/product-of-array-except-self/HYUNAHKO.py b/product-of-array-except-self/HYUNAHKO.py index 55498d54e5..a475e56995 100644 --- a/product-of-array-except-self/HYUNAHKO.py +++ b/product-of-array-except-self/HYUNAHKO.py @@ -16,25 +16,4 @@ def productExceptSelf(self, nums: List[int]) -> List[int]: p *= nums[i] return result_list - - - -class Solution: - def productExceptSelf(self, nums: List[int]) -> List[int]: - result_list = [0] * len(nums) - if len(nums) <2 or len(nums) > 1e5: - return None - - for idx in range(0, len(nums)): - result = 1 - for idx_left in range(0, idx): - result *= nums[idx_left] - - for idx_right in range(idx+1, len(nums)): - result *= nums[idx_right] - - result_list[idx] = result - - - return result_list \ No newline at end of file diff --git a/valid-palindrome/HYUNAHKO.py b/valid-palindrome/HYUNAHKO.py index 2baf8d8077..81a5355010 100644 --- a/valid-palindrome/HYUNAHKO.py +++ b/valid-palindrome/HYUNAHKO.py @@ -9,4 +9,3 @@ def isPalindrome(self, s: str) -> bool: if (str1 != result[n-i-1]): return False return True - \ No newline at end of file From 62dad6b4dddc91ae8830810269ae68f5cf1fc48e Mon Sep 17 00:00:00 2001 From: HYUNAHKO Date: Sat, 29 Nov 2025 10:28:48 +0900 Subject: [PATCH 11/12] resolve merge conflict --- product-of-array-except-self/HYUNAHKO.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product-of-array-except-self/HYUNAHKO.py b/product-of-array-except-self/HYUNAHKO.py index a475e56995..a7b8747b2c 100644 --- a/product-of-array-except-self/HYUNAHKO.py +++ b/product-of-array-except-self/HYUNAHKO.py @@ -16,4 +16,4 @@ def productExceptSelf(self, nums: List[int]) -> List[int]: p *= nums[i] return result_list - \ No newline at end of file + \ No newline at end of file From b6436f71ebed68a258b63011ae4f416d96ddd4aa Mon Sep 17 00:00:00 2001 From: HYUNAHKO Date: Sat, 29 Nov 2025 10:58:31 +0900 Subject: [PATCH 12/12] Real Final resolve merge conflict --- product-of-array-except-self/HYUNAHKO.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/product-of-array-except-self/HYUNAHKO.py b/product-of-array-except-self/HYUNAHKO.py index a7b8747b2c..947f741547 100644 --- a/product-of-array-except-self/HYUNAHKO.py +++ b/product-of-array-except-self/HYUNAHKO.py @@ -8,12 +8,11 @@ def productExceptSelf(self, nums: List[int]) -> List[int]: p = 1 for i in range(n): result_list[i] = p - p *= nums[i] - + p *= nums[i] + p = 1 for i in range(n - 1, -1, -1): result_list[i] *= p p *= nums[i] return result_list - \ No newline at end of file