From 4282305f7f657f493ba0c373f19ee20d65c2aeb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8C=80=ED=98=84=20=28Kim=20DaeHyun=29?= Date: Tue, 30 Jun 2026 00:29:45 +0900 Subject: [PATCH 1/4] Solve Valid-Anagram --- valid-anagram/daehyun99.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 valid-anagram/daehyun99.py diff --git a/valid-anagram/daehyun99.py b/valid-anagram/daehyun99.py new file mode 100644 index 0000000000..bfcc871ed1 --- /dev/null +++ b/valid-anagram/daehyun99.py @@ -0,0 +1,16 @@ +from collections import defaultdict +class Solution: + def isAnagram(self, s: str, t: str) -> bool: + count = defaultdict(int) + + if len(s) != len(t): + return False + + for s_, t_ in zip(s, t): + count[s_] += 1 + count[t_] -= 1 + + for key, val in count.items(): + if val != 0: + return False + return True From d678b085b78428a2ec74d1dfd863ad1937f07eb1 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Tue, 30 Jun 2026 17:31:33 +0900 Subject: [PATCH 2/4] Solve: Climbing Stairs --- climbing-stairs/daehyun99.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 climbing-stairs/daehyun99.py diff --git a/climbing-stairs/daehyun99.py b/climbing-stairs/daehyun99.py new file mode 100644 index 0000000000..09681c6150 --- /dev/null +++ b/climbing-stairs/daehyun99.py @@ -0,0 +1,20 @@ +class Solution: + def climbStairs(self, n: int) -> int: + one_count = n + two_count = 0 + total_count = 0 + + while one_count >=0 and two_count >=0: + # 조합 + total = one_count + two_count + + count = 1 + for i in range(two_count): + count *= total - i + for i in range(two_count, 0, -1): + count /= i + total_count += count + + one_count -=2 + two_count +=1 + return int(total_count) From 15f3895a75ebbf479100404de57168a053d04c8e Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Wed, 1 Jul 2026 18:59:24 +0900 Subject: [PATCH 3/4] Solve: Product of Array except self --- product-of-array-except-self/daehyun99.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 product-of-array-except-self/daehyun99.py diff --git a/product-of-array-except-self/daehyun99.py b/product-of-array-except-self/daehyun99.py new file mode 100644 index 0000000000..26e3fee3e2 --- /dev/null +++ b/product-of-array-except-self/daehyun99.py @@ -0,0 +1,18 @@ +class Solution: + def productExceptSelf(self, nums: List[int]) -> List[int]: + product = 1 + zero_pos = set() + + for i in range(len(nums)): + num = nums[i] + if num != 0: + product *= num + else: + zero_pos.add(i) + + if len(zero_pos) >= 2: + return [0 for num in nums] + elif len(zero_pos) == 1: + return [0 if i not in zero_pos else product for i in range(len(nums))] + else: + return [int(product / num) for num in nums] From 70b226acd84a881ec559871a93dd42dc2c2275dc Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Fri, 3 Jul 2026 20:02:05 +0900 Subject: [PATCH 4/4] Solve --- 3sum/daehyun99.py | 51 ++++++++++++++++++++++++ validate-binary-search-tree/daehyun99.py | 20 ++++++++++ 2 files changed, 71 insertions(+) create mode 100644 3sum/daehyun99.py create mode 100644 validate-binary-search-tree/daehyun99.py diff --git a/3sum/daehyun99.py b/3sum/daehyun99.py new file mode 100644 index 0000000000..8f21f2c019 --- /dev/null +++ b/3sum/daehyun99.py @@ -0,0 +1,51 @@ +class Solution: + def threeSum(self, nums: List[int]) -> List[List[int]]: + res = [] + nums.sort() + + for i, a in enumerate(nums): + if a > 0: + break + if i > 0 and a == nums[i-1]: + continue + + l, r = i+1, len(nums) - 1 + while l < r: + total = a + nums[l] + nums[r] + if total > 0: + r -= 1 + elif total < 0: + l += 1 + else: + res.append([a, nums[l], nums[r]]) + l += 1 + r -= 1 + while nums[l] == nums[l - 1] and l < r: + l += 1 + return res + +"""from collections import Counter + +class Solution: + def threeSum(self, nums: list[int]) -> list[list[int]]: + counts = Counter(nums) + result: set[tuple[int, int, int]] = set() + + for i in range(len(nums) - 2): + for j in range(i + 1, len(nums) - 1): + adding = -(nums[i] + nums[j]) + + if adding not in counts: + continue + + local_counts = Counter([nums[i], nums[j], adding]) + + for num, count in local_counts.items(): + if counts[num] < count: + break + else: + triplet = tuple(sorted([nums[i], nums[j], adding])) + result.add(triplet) + + return [list(triplet) for triplet in result] +""" diff --git a/validate-binary-search-tree/daehyun99.py b/validate-binary-search-tree/daehyun99.py new file mode 100644 index 0000000000..96018c617e --- /dev/null +++ b/validate-binary-search-tree/daehyun99.py @@ -0,0 +1,20 @@ +# 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: + def valid(node, left, right): + if not node: + return True + if not (left < node.val < right): + return False + + return ( + valid(node.left, left, node.val) and + valid(node.right, node.val, right) + ) + return valid(root, float("-inf"), float("inf"))