From 85ef5696828ca3f49e829fbd63f969fa23d4ee42 Mon Sep 17 00:00:00 2001 From: jla670 Date: Sun, 5 Apr 2026 16:28:00 -0700 Subject: [PATCH 1/5] valid parentheses solution --- valid-parentheses/jylee2033.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 valid-parentheses/jylee2033.py diff --git a/valid-parentheses/jylee2033.py b/valid-parentheses/jylee2033.py new file mode 100644 index 0000000000..1cffb25248 --- /dev/null +++ b/valid-parentheses/jylee2033.py @@ -0,0 +1,25 @@ +class Solution: + def isValid(self, s: str) -> bool: + close_to_open = {')': '(', '}': '{', ']': '['} + stack = [] # Open brackets + + if len(s) % 2 == 1: + return False + + for ch in s: + # Open bracket + if ch in close_to_open.values(): + stack.append(ch) + # Close bracket + else: + if len(stack) == 0: + return False + + expected = close_to_open[ch] + if stack.pop() != expected: + return False + + return len(stack) == 0 + +# Time Complexity: O(n) +# Space Complexity: O(n) From a199b08a88f7a00de7bd25de222d60aa4653b730 Mon Sep 17 00:00:00 2001 From: jla670 Date: Thu, 9 Apr 2026 16:33:39 -0700 Subject: [PATCH 2/5] container with most water solution --- container-with-most-water/jylee2033.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 container-with-most-water/jylee2033.py diff --git a/container-with-most-water/jylee2033.py b/container-with-most-water/jylee2033.py new file mode 100644 index 0000000000..e39ec0677d --- /dev/null +++ b/container-with-most-water/jylee2033.py @@ -0,0 +1,19 @@ +class Solution: + def maxArea(self, height: List[int]) -> int: + left = 0 + right = len(height) - 1 + area = min(height[left], height[right]) * (right - left) + + while left < right: + if height[left] < height[right]: + left += 1 + else: + right -= 1 + + new_area = min(height[left], height[right]) * (right - left) + area = max(area, new_area) + + return area + +# Time Complexity: O(n) +# Space Complexity: O(1) From 95b8c702385cc04f15343b98061ec945b0ba4c70 Mon Sep 17 00:00:00 2001 From: jla670 Date: Fri, 10 Apr 2026 14:34:52 -0700 Subject: [PATCH 3/5] design add and search words data structure solution --- .../jylee2033.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 design-add-and-search-words-data-structure/jylee2033.py diff --git a/design-add-and-search-words-data-structure/jylee2033.py b/design-add-and-search-words-data-structure/jylee2033.py new file mode 100644 index 0000000000..77b6492678 --- /dev/null +++ b/design-add-and-search-words-data-structure/jylee2033.py @@ -0,0 +1,41 @@ +class WordDictionary: + + def __init__(self): + self.children = {} # key: character, value: WordDictionary node + self.is_end = False + + # Time Complexity: O(n), n - length of the word + # Space Complexity: O(N * n), N - number of words, n - length of the word + def addWord(self, word: str) -> None: + cur = self + + for char in word: + if char not in cur.children: + cur.children[char] = WordDictionary() + cur = cur.children[char] + + cur.is_end = True + + # Time Complexity: O(26^n), n - length of the word + # Space Complexity: O(n^2), n - length of the word + def search(self, word: str) -> bool: + cur = self + + for i, char in enumerate(word): + if char == ".": + for child in cur.children.values(): + if child.search(word[i + 1:]): + return True + return False + + elif char not in cur.children: + return False + + cur = cur.children[char] + + return cur.is_end + +# Your WordDictionary object will be instantiated and called as such: +# obj = WordDictionary() +# obj.addWord(word) +# param_2 = obj.search(word) From 714420c42145e84fe5f160c21a571f74c57bbd21 Mon Sep 17 00:00:00 2001 From: jla670 Date: Fri, 10 Apr 2026 17:41:12 -0700 Subject: [PATCH 4/5] add hello --- container-with-most-water/jylee2033.py | 1 + 1 file changed, 1 insertion(+) diff --git a/container-with-most-water/jylee2033.py b/container-with-most-water/jylee2033.py index e39ec0677d..a068fdf2c6 100644 --- a/container-with-most-water/jylee2033.py +++ b/container-with-most-water/jylee2033.py @@ -17,3 +17,4 @@ def maxArea(self, height: List[int]) -> int: # Time Complexity: O(n) # Space Complexity: O(1) +# Hello From e187b7f40de57b528ce0faa6c984a3a3230fa2aa Mon Sep 17 00:00:00 2001 From: jla670 Date: Fri, 10 Apr 2026 18:59:19 -0700 Subject: [PATCH 5/5] remove hello --- container-with-most-water/jylee2033.py | 1 - 1 file changed, 1 deletion(-) diff --git a/container-with-most-water/jylee2033.py b/container-with-most-water/jylee2033.py index a068fdf2c6..e39ec0677d 100644 --- a/container-with-most-water/jylee2033.py +++ b/container-with-most-water/jylee2033.py @@ -17,4 +17,3 @@ def maxArea(self, height: List[int]) -> int: # Time Complexity: O(n) # Space Complexity: O(1) -# Hello