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
Whenever you're ready, walk me through your approach or go straight to the code. The requirements are in the Question tab.