20. Valid Parentheses

Practice Valid Parentheses for free on NudgeCode: Easy, Stack pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Given a string s made only of the characters ()[]{}, return whether it is valid.

A string is valid when every opening bracket is closed by the same type of bracket, and brackets close in the correct order.

Example

s = "()[]{}"  ->  true
s = "(]"      ->  false

Constraints