Given a string s consisting of parentheses (, ), {, }, [, and ], write a function to determine if the input string is valid. An input string is valid if:
Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Constraints
0 <= s.length <= 10^4
s consists of parentheses only
Function Signature
defis_valid(s: str) -> bool:
Interviewer
Your question is Validate Balanced Parentheses String. Start with the requirements in the Question tab.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.