Balanced Parentheses
Easyjavapythonccppjavascript
Given a string containing only the characters (), {} and [], determine whether every bracket is correctly opened and closed in the correct order.
Input Format
A single line containing the bracket string S.
Output Format
Print 1 if the brackets are balanced, otherwise print 0.
Example 1
Input
{[()]}Output
1
Explanation: Every opening bracket has the matching closing bracket in the correct order.
- 1 <= length of S <= 100000
- S contains only the characters ( ) { } [ ]