src.valid_parenthesis¶
Classes
|
- class src.valid_parenthesis.Solution[source][source]¶
- isValid(s: str) bool [source]¶
Thought process¶
I think a good way to think about this is the False and Passing condition
False condition : false condition without corresponding opening bracket
Passing condition : stack is empty, signifying that all brackets have been closed
We can use a dictionary to map the closing brackets to the opening brackets
Notes¶
time complexity is \(O(n)\)
space complexity is \(O(n)\)