From 5008b80058de7b5edf040de7afdd43e3dbe95a40 Mon Sep 17 00:00:00 2001 From: doh6077 Date: Mon, 15 Dec 2025 17:03:00 -0500 Subject: [PATCH 1/2] 20. Valid Parentheses Solution --- valid-parentheses/doh6077.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 valid-parentheses/doh6077.py diff --git a/valid-parentheses/doh6077.py b/valid-parentheses/doh6077.py new file mode 100644 index 000000000..483b76cae --- /dev/null +++ b/valid-parentheses/doh6077.py @@ -0,0 +1,16 @@ +# Use stack and Hashmap +class Solution: + def isValid(self, s: str) -> bool: + match = {")": "(", "}": "{", "]": "["} + stack = [] + + for ch in s: + if ch in match: + if stack and stack[-1] == match[ch]: + stack.pop() + else: + return False + else: + stack.append(ch) + return True if not stack else False + From 323fa15edd292259541209ce1627a1dfd68777e7 Mon Sep 17 00:00:00 2001 From: doh6077 Date: Mon, 15 Dec 2025 17:26:03 -0500 Subject: [PATCH 2/2] 11. Container With Most Water Solution --- container-with-most-water/doh6077.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 container-with-most-water/doh6077.py diff --git a/container-with-most-water/doh6077.py b/container-with-most-water/doh6077.py new file mode 100644 index 000000000..907db9516 --- /dev/null +++ b/container-with-most-water/doh6077.py @@ -0,0 +1,16 @@ +# 11. Container With Most Water + +# Use two pointesr +class Solution: + def maxArea(self, height: List[int]) -> int: + left, right = 0, len(height) -1 + container = 0 + + while left < right: + cal = ((right - left) * min(height[left], height[right])) + container = max(container, cal) + if height[left] > height[right]: + right -= 1 + else: + left += 1 + return container