Loading...
Loading...
Loading...
A line holds only the characters (, ), [, ], { and }. Print yes if every bracket is closed by the same kind in the right order, and no otherwise. The starter holds a program with a bug. Find it and fix it.
yes or no.Example 1
Input
([]{})Output
yes
Every bracket closes in order.
Example 2
Input
([)]
Output
no
The counts match but the order is wrong.
Try the problem first. Open one hint at a time.
Use a stack: push every opening bracket.
On a closing bracket, the top of the stack must be its partner.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor