From 58fc935a51a9f115c48e481909e5e4e0a3c7320d Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Mon, 27 Jul 2026 23:21:54 +0100 Subject: [PATCH 1/3] Implement valid parentheses solution --- valid-parentheses/Chanz82.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 valid-parentheses/Chanz82.py diff --git a/valid-parentheses/Chanz82.py b/valid-parentheses/Chanz82.py new file mode 100644 index 0000000000..d56bed3773 --- /dev/null +++ b/valid-parentheses/Chanz82.py @@ -0,0 +1,20 @@ +class Solution: + def isValid(self, s: str) -> bool: + ch_stack = [] + ch_map = {} + + ch_map[")"] = "(" + ch_map["}"] = "{" + ch_map["]"] = "[" + + for ch in s: + if ch == ")" or ch == "}" or ch == "]": + if not ch_stack: + return False + if ch_stack.pop() != ch_map[ch]: + return False + else: + ch_stack.append(ch) + + return not ch_stack + From d0c7298fb9002ce110517ba90d2094a0b38df771 Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Tue, 28 Jul 2026 00:05:08 +0100 Subject: [PATCH 2/3] water container problem solution --- container-with-most-water/Chanz82.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 container-with-most-water/Chanz82.py diff --git a/container-with-most-water/Chanz82.py b/container-with-most-water/Chanz82.py new file mode 100644 index 0000000000..13571e6c14 --- /dev/null +++ b/container-with-most-water/Chanz82.py @@ -0,0 +1,21 @@ +class Solution: + def maxArea(self, height: List[int]) -> int: + # 두 점의 거리가 길어야 하고, 높은 막대기들끼리 있어야 많은 물을 채울 수 있음. + # 양쪽의 점부터 시작해서 더 줄여볼지 말지를 판단 해 볼 수 있을 것 같음. + + def caculate_water_container(left, right): + return (right - left) * min(height[left], height[right]) + + left = 0 + right = len(height) - 1 + max_water = 0 + + while left <= right: + max_water = max(max_water, caculate_water_container(left, right)) + if height[left] > height[right] : + right -= 1 + else : + left += 1 + + return max_water + From 0b834bf759bce5d188cf1bd1ebeb21e5d8a44bce Mon Sep 17 00:00:00 2001 From: Hyun Chan Park <126567839+Chanz82@users.noreply.github.com> Date: Sat, 1 Aug 2026 11:30:57 +0100 Subject: [PATCH 3/3] Add a solution for Design Add and Search Words Data Structure --- .../Chanz82.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 design-add-and-search-words-data-structure/Chanz82.py diff --git a/design-add-and-search-words-data-structure/Chanz82.py b/design-add-and-search-words-data-structure/Chanz82.py new file mode 100644 index 0000000000..b7e4cc94d4 --- /dev/null +++ b/design-add-and-search-words-data-structure/Chanz82.py @@ -0,0 +1,40 @@ +class WordDictionary: + + def __init__(self): + self.word_tree = {} + + def addWord(self, word: str) -> None: + curr_branch = self.word_tree + for ch in word: + if not curr_branch.get(ch, None): + curr_branch[ch] = {} + curr_branch = curr_branch[ch] + curr_branch["#"] = {} # end of word + + def search(self, word: str) -> bool: + curr_branch = self.word_tree + + def nested_search(start_branch: dict, word: str) -> bool: + + for idx, ch in enumerate(word): + if ch in start_branch: + start_branch = start_branch[ch] + elif ch == ".": + for branch in start_branch.values(): + if nested_search(branch, word[idx+1:]): + return True + return False + else: + return False + + if "#" in start_branch: + return True + + return False + + return nested_search(curr_branch, word) + +# Your WordDictionary object will be instantiated and called as such: +# obj = WordDictionary() +# obj.addWord(word) +# param_2 = obj.search(word)