From 3b6b3eac0a4b2f40861a88d2770a313977f901df Mon Sep 17 00:00:00 2001 From: Hojeong Park Date: Sat, 4 Jul 2026 02:23:42 +0900 Subject: [PATCH 1/8] valid anagram solution --- valid-anagram/parkhojeong.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 valid-anagram/parkhojeong.py diff --git a/valid-anagram/parkhojeong.py b/valid-anagram/parkhojeong.py new file mode 100644 index 0000000000..b755e03fb8 --- /dev/null +++ b/valid-anagram/parkhojeong.py @@ -0,0 +1,5 @@ +from collections import Counter + +class Solution: + def isAnagram(self, s: str, t: str) -> bool: + return Counter(s) == Counter(t) From efee3c7c1ae1300af0d11faebccd33bcc7401bb3 Mon Sep 17 00:00:00 2001 From: Hojeong Park Date: Sat, 4 Jul 2026 02:23:49 +0900 Subject: [PATCH 2/8] climbing stairs solution --- climbing-stairs/parkhojeong.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 climbing-stairs/parkhojeong.py diff --git a/climbing-stairs/parkhojeong.py b/climbing-stairs/parkhojeong.py new file mode 100644 index 0000000000..2baac4f048 --- /dev/null +++ b/climbing-stairs/parkhojeong.py @@ -0,0 +1,13 @@ +class Solution: + def climbStairs(self, n: int) -> int: + if n == 1: + return 1 + + arr = [0] * n + arr[0] = 1 + arr[1] = 2 + for i in range(2, n): + arr[i] = arr[i - 1] + arr[i - 2] + + return arr[n - 1] + From 45ac2b32c314f6bf57ae3b9527e2b6fc5abf1042 Mon Sep 17 00:00:00 2001 From: Hojeong Park Date: Sat, 4 Jul 2026 02:23:55 +0900 Subject: [PATCH 3/8] product of array except self solution --- product-of-array-except-self/parkhojeong.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 product-of-array-except-self/parkhojeong.py diff --git a/product-of-array-except-self/parkhojeong.py b/product-of-array-except-self/parkhojeong.py new file mode 100644 index 0000000000..1a0fd867c7 --- /dev/null +++ b/product-of-array-except-self/parkhojeong.py @@ -0,0 +1,17 @@ +class Solution: + def productExceptSelf(self, nums: List[int]) -> List[int]: + zero_count = nums.count(0) + + if zero_count >= 2: + return [0] * len(nums) + + multiplied = 1 + for num in nums: + if num == 0: + continue + multiplied = multiplied * num + + if zero_count == 1: + return [multiplied if x == 0 else 0 for x in nums] + + return [int(multiplied / x) for x in nums] From 7059ab1a7a886dce73ed1e2a14d0edf2558794d6 Mon Sep 17 00:00:00 2001 From: Hojeong Park Date: Sat, 4 Jul 2026 02:24:00 +0900 Subject: [PATCH 4/8] validate binary search tree solution --- validate-binary-search-tree/parkhojeong.py | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 validate-binary-search-tree/parkhojeong.py diff --git a/validate-binary-search-tree/parkhojeong.py b/validate-binary-search-tree/parkhojeong.py new file mode 100644 index 0000000000..2fdebc9eb6 --- /dev/null +++ b/validate-binary-search-tree/parkhojeong.py @@ -0,0 +1,24 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def isValidBST(self, root: Optional[TreeNode]) -> bool: + return self.dfs(root, ~sys.maxsize, sys.maxsize) + + def dfs(self, root, min_val, max_val) -> bool: + val = root.val + if val <= min_val or val >= max_val: + return False + + if root.left: + if not self.dfs(root.left, min_val, val): + return False + if root.right: + if not self.dfs(root.right, val, max_val): + return False + + return True + From f1fa20ec552d2b1051d9de3eeeef18e7426ec783 Mon Sep 17 00:00:00 2001 From: Hojeong Park Date: Sat, 4 Jul 2026 03:24:53 +0900 Subject: [PATCH 5/8] update product-of-array-except-self solution without division operation --- product-of-array-except-self/parkhojeong.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/product-of-array-except-self/parkhojeong.py b/product-of-array-except-self/parkhojeong.py index 1a0fd867c7..d257d8cf2f 100644 --- a/product-of-array-except-self/parkhojeong.py +++ b/product-of-array-except-self/parkhojeong.py @@ -1,17 +1,14 @@ class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: - zero_count = nums.count(0) + n = len(nums) + answer = [1] * n - if zero_count >= 2: - return [0] * len(nums) + for i in range(1, n): + answer[i] = answer[i -1] * nums[i - 1] - multiplied = 1 - for num in nums: - if num == 0: - continue - multiplied = multiplied * num + R = 1 + for i in range(n - 1, -1, -1): + answer[i] *= R + R *= nums[i] - if zero_count == 1: - return [multiplied if x == 0 else 0 for x in nums] - - return [int(multiplied / x) for x in nums] + return answer From 543e06ec1f97537eab0d959d630c465492a01d89 Mon Sep 17 00:00:00 2001 From: Hojeong Park Date: Sat, 4 Jul 2026 03:24:53 +0900 Subject: [PATCH 6/8] 3sum solution --- 3sum/parkhojeong.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 3sum/parkhojeong.py diff --git a/3sum/parkhojeong.py b/3sum/parkhojeong.py new file mode 100644 index 0000000000..caf5268157 --- /dev/null +++ b/3sum/parkhojeong.py @@ -0,0 +1,32 @@ +class Solution: + def threeSum(self, nums: list[int]) -> list[list[int]]: + result_arr = [] + n = nums + + n.sort() + + for i in range(len(n) - 2): + if n[i] > 0: + break + if i > 0 and n[i] == n[i - 1]: + continue + + j = i + 1 + k = len(n) - 1 + while j < k: + sum = n[i] + n[j] + n[k] + + if sum == 0: + result_arr.append([n[i], n[j], n[k]]) + while j < k and n[j] == n[j + 1]: + j += 1 + while j < k and n[k] == n[k - 1]: + k -= 1 + j += 1 + k -= 1 + elif sum > 0: + k -= 1 + else: + j += 1 + + return result_arr From a2e3989a237177583a67664c52af3122d85282e0 Mon Sep 17 00:00:00 2001 From: Hojeong Park Date: Sat, 4 Jul 2026 14:02:43 +0900 Subject: [PATCH 7/8] update climbing-stairs --- climbing-stairs/parkhojeong.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/climbing-stairs/parkhojeong.py b/climbing-stairs/parkhojeong.py index 2baac4f048..f6ad523ad7 100644 --- a/climbing-stairs/parkhojeong.py +++ b/climbing-stairs/parkhojeong.py @@ -4,10 +4,10 @@ def climbStairs(self, n: int) -> int: return 1 arr = [0] * n - arr[0] = 1 - arr[1] = 2 + arr[0], arr[1] = 1, 2 + for i in range(2, n): arr[i] = arr[i - 1] + arr[i - 2] - return arr[n - 1] + return arr[-1] From 4ed105c3a9dd6fe007432b9cb7780877b4b2f990 Mon Sep 17 00:00:00 2001 From: Hojeong Park Date: Sat, 4 Jul 2026 16:12:48 +0900 Subject: [PATCH 8/8] update 3sum --- 3sum/parkhojeong.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/3sum/parkhojeong.py b/3sum/parkhojeong.py index caf5268157..837d05362c 100644 --- a/3sum/parkhojeong.py +++ b/3sum/parkhojeong.py @@ -1,30 +1,29 @@ class Solution: def threeSum(self, nums: list[int]) -> list[list[int]]: result_arr = [] - n = nums + n = len(nums) + nums.sort() - n.sort() - - for i in range(len(n) - 2): - if n[i] > 0: + for i in range(n - 2): + if nums[i] > 0: break - if i > 0 and n[i] == n[i - 1]: + if i > 0 and nums[i] == nums[i - 1]: continue j = i + 1 - k = len(n) - 1 + k = n - 1 while j < k: - sum = n[i] + n[j] + n[k] + total = nums[i] + nums[j] + nums[k] - if sum == 0: - result_arr.append([n[i], n[j], n[k]]) - while j < k and n[j] == n[j + 1]: + if total == 0: + result_arr.append([nums[i], nums[j], nums[k]]) + while j < k and nums[j] == nums[j + 1]: j += 1 - while j < k and n[k] == n[k - 1]: + while j < k and nums[k] == nums[k - 1]: k -= 1 j += 1 k -= 1 - elif sum > 0: + elif total > 0: k -= 1 else: j += 1