Skip to content
Open
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
12 changes: 12 additions & 0 deletions algorithms/valid-parentheses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution:

Check failure on line 1 in algorithms/valid-parentheses.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

algorithms/valid-parentheses.py:1:1: INP001 File `algorithms/valid-parentheses.py` is part of an implicit namespace package. Add an `__init__.py`.
def isValid(self, s):

Check failure on line 2 in algorithms/valid-parentheses.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N802)

algorithms/valid-parentheses.py:2:9: N802 Function name `isValid` should be lowercase
stack = []
mapping = {")": "(", "}": "{", "]": "["}
for char in s:
if char in mapping:
top = stack.pop() if stack else "#"
if mapping[char] != top:
return False
else:
stack.append(char)
return not stack
Loading