From 4ca5a3033b2548e6f91d00ff79b09508f851826a Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Mon, 27 Jul 2026 17:22:20 +0900 Subject: [PATCH 1/6] Solve: isValid --- valid-parentheses/daehyun99.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 valid-parentheses/daehyun99.py diff --git a/valid-parentheses/daehyun99.py b/valid-parentheses/daehyun99.py new file mode 100644 index 0000000000..084b06699a --- /dev/null +++ b/valid-parentheses/daehyun99.py @@ -0,0 +1,16 @@ +class Solution: + def isValid(self, s: str) -> bool: + stack = [] + + map = {"()", "{}", "[]"} + + for char in s: + stack.append(char) + if len(stack) >= 2: + if ''.join(stack[-2:]) in map: + stack.pop() + stack.pop() + if len(stack) == 0: + return True + else: + return False From 3bfcd7eb5241d7903d67f091849c8b68f3f60657 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Tue, 28 Jul 2026 14:30:03 +0900 Subject: [PATCH 2/6] Solve: maxArea --- container-with-most-water/daehyun99.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 container-with-most-water/daehyun99.py diff --git a/container-with-most-water/daehyun99.py b/container-with-most-water/daehyun99.py new file mode 100644 index 0000000000..c441cc9b30 --- /dev/null +++ b/container-with-most-water/daehyun99.py @@ -0,0 +1,19 @@ +# Time: O(N) +# Space: O(1) +class Solution: + def maxArea(self, height: List[int]) -> int: + size = 0 + l, r = 0, len(height)-1 + length = len(height)-1 + + while l < r: + if height[l] < height[r]: + size = max(size, height[l] * length) + l += 1 + length -= 1 + else: + size = max(size, height[r] * length) + r -= 1 + length -= 1 + return size + \ No newline at end of file From e639254dddf946c510592517201625d5d919b25e Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Wed, 29 Jul 2026 14:13:52 +0900 Subject: [PATCH 3/6] Solve: WordDictionary --- .../daehyun99.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 design-add-and-search-words-data-structure/daehyun99.py diff --git a/design-add-and-search-words-data-structure/daehyun99.py b/design-add-and-search-words-data-structure/daehyun99.py new file mode 100644 index 0000000000..6c105daf4a --- /dev/null +++ b/design-add-and-search-words-data-structure/daehyun99.py @@ -0,0 +1,39 @@ +class WordDictionary: + + def __init__(self): + self.root = {} + + def addWord(self, word: str) -> None: + pointer = self.root + for char in word: + if char in pointer: + pointer = pointer[char] + else: + pointer[char] = {} + pointer = pointer[char] + pointer["0"]={} + + def search(self, word: str) -> bool: + from collections import deque + pointer = self.root + que = deque() + que.append(pointer) + + for char in word: + for i in range(len(que)): + pointer = que.popleft() + if char in pointer: + que.append(pointer[char]) + elif char == ".": + for key in pointer.keys(): + que.append(pointer[key]) + while len(que) > 0: + pointer = que.popleft() + if "0" in pointer: + return True + return False + +# Your WordDictionary object will be instantiated and called as such: +# obj = WordDictionary() +# obj.addWord(word) +# param_2 = obj.search(word) From 827ef7f2edc3ca1589943e3756f8fc63a35641b5 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Thu, 30 Jul 2026 16:18:51 +0900 Subject: [PATCH 4/6] Solve: lengthOfLIS --- longest-increasing-subsequence/daehyun99.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 longest-increasing-subsequence/daehyun99.py diff --git a/longest-increasing-subsequence/daehyun99.py b/longest-increasing-subsequence/daehyun99.py new file mode 100644 index 0000000000..af00231962 --- /dev/null +++ b/longest-increasing-subsequence/daehyun99.py @@ -0,0 +1,11 @@ +# Time: O(N**2) +# Space: O(N) +class Solution: + def lengthOfLIS(self, nums: List[int]) -> int: + counts = [1 for i in nums] + + for i in range(1, len(nums)): + for j in range(0, i): + if nums[j] < nums[i]: + counts[i] = max(counts[i], counts[j]+1) + return max(counts) From 31597dac92385d0a713a20f94f379a0d957af3a2 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Fri, 31 Jul 2026 15:53:34 +0900 Subject: [PATCH 5/6] Solve: spiralOrder --- spiral-matrix/daehyun99.py | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 spiral-matrix/daehyun99.py diff --git a/spiral-matrix/daehyun99.py b/spiral-matrix/daehyun99.py new file mode 100644 index 0000000000..c9ec0e3e72 --- /dev/null +++ b/spiral-matrix/daehyun99.py @@ -0,0 +1,55 @@ +class Solution: + def spiralOrder(self, matrix: List[List[int]]) -> List[int]: + height = len(matrix) + weight = len(matrix[0]) + adding = [ + [0, 1], + [1, 0], + [0, -1], + [-1, 0] + ] + m = 0 + n = -1 + size = height * weight + count = 0 + + result = [] + + while count < size: + if 0 < weight and count < size: + m_add, n_add = adding[0] + for _ in range(weight): + m += m_add + n += n_add + result.append(matrix[m][n]) + count += 1 + + height -= 1 + if 0 < height and count < size: + m_add, n_add = adding[1] + for _ in range(height): + m += m_add + n += n_add + result.append(matrix[m][n]) + count += 1 + + weight -= 1 + if 0 < weight and count < size: + m_add, n_add = adding[2] + for _ in range(weight): + m += m_add + n += n_add + result.append(matrix[m][n]) + count += 1 + + height -= 1 + if 0 < height and count < size: + m_add, n_add = adding[3] + for _ in range(height): + m += m_add + n += n_add + result.append(matrix[m][n]) + count += 1 + + weight -= 1 + return result From cf5757b9f644db7006c3481fc3ef00bf7cdb9ac1 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Sat, 1 Aug 2026 15:54:54 +0900 Subject: [PATCH 6/6] fix lint error --- container-with-most-water/daehyun99.py | 1 - 1 file changed, 1 deletion(-) diff --git a/container-with-most-water/daehyun99.py b/container-with-most-water/daehyun99.py index c441cc9b30..2a086277ee 100644 --- a/container-with-most-water/daehyun99.py +++ b/container-with-most-water/daehyun99.py @@ -16,4 +16,3 @@ def maxArea(self, height: List[int]) -> int: r -= 1 length -= 1 return size - \ No newline at end of file