Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions container-with-most-water/doh6077.py
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions valid-parentheses/doh6077.py
Original file line number Diff line number Diff line change
@@ -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