Dsa
Stack
Easy
Balanced Brackets Checker
You are tasked with creating a program that checks if a string of brackets is balanced. A string is considered balanced if for every opening bracket there is a corresponding closing bracket and they are properly nested. The brackets to be considered are: '(', ')', '{', '}', '[', ']'.
Input format:
- A single string containing a sequence of brackets (1 <= length <= 10^5).
Output format:
- Print 'YES' if the brackets are balanced, otherwise print 'NO'.
Example:
Input:
{[()()]}
Output:
YES
Key concepts
stackbracketsvalidation
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