PRACTICE · STACKS
Valid Parentheses
The challenge
Given a string containing brackets, decide whether every opening bracket has a matching closing bracket of the same type, in the correct order.
Example
Input s = "({[]})"
Output true
Every pair closes in the reverse order it was opened.
Before you begin
- Read through the example and consider edge cases.
- Write down a simple solution before optimizing.
- Describe the time and space complexity of your approach.
A space to understand the problem. Use your favorite editor to write and run your solution.