Dsa
Stack
Medium
Balanced Brackets Sequence
You are given a string consisting of various types of brackets: '(', ')', '{', '}', '[' and ']'. Write a program to determine if the brackets are balanced. A string is considered balanced if: 1) Every opening bracket has a corresponding closing bracket, and 2) The brackets are closed in the correct order. Print 'True' if the string is balanced and 'False' otherwise.
Input Format:
A single line containing the string of brackets.
Output Format:
A single line with 'True' or 'False'.
Example:
Input:
{[()]}
Output:
True
Key concepts
stackstring
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now