| 20 | """ |
| 21 | |
| 22 | class Solution: |
| 23 | def isValid(self, s: str) -> bool: |
| 24 | parentheses = {'(':')', '{':'}', '[':']'} |
| 25 | stack = [] |
| 26 | for b in s: # take bracket 'b' from string 's' |
| 27 | if b in parentheses: # if bracket in parentheses |
| 28 | stack.append(parentheses[b]) # append it's opposite to stack |
| 29 | elif not stack or stack.pop() != b: # if not stack or bracket not |
| 30 | return False # equal last bracket in stack |
| 31 | return not stack # if stack still exists -> False else True |
nothing calls this directly
no outgoing calls
no test coverage detected