BasicAlgorithms10 points
Does this template close properly?
A code editor used by a software team in Bengaluru highlights an error when brackets in a file are not closed properly. A bracket string is balanced when every opening bracket is closed by the matching type of bracket, in the correct order (so ([]) is balanced but ([)] and (() are not).
Task: the input is a single line of 1 to 400 characters, each one of ( ) [ ] { }. Print YES if the string is balanced, otherwise print NO.
Sample test
Input
{[()]}()Expected output
YES
Your answer is also checked against 6 hidden tests.
Need a hint?
Think of a stack of plates: the most recent opening bracket must be the first one to be closed.
Python 3
10 pts
Loading editor...
Log in or create a free account to run your code, submit and earn points.
Run your code to see the output here. Ctrl + Enter also runs it.
