Overview
Brackets balanced hain ya nahi check karo — stack ka classic use case.
Analogy
Jaise dost ka kaam karo — jo khola wahi band karo, aur order sahi hona chahiye.
Step-by-step
- Stack use karo
- Opening bracket: stack pe push karo
- Closing bracket: stack top se match karo
- End mein stack empty honi chahiye
Visual
"({[]})" -> push ( { [ -> ] matches [ -> } matches { -> ) matches ( -> stack empty OK
"({)" -> stack has { remaining FAIL
Common mistakes
- Empty stack pe pop — IndexError
- End mein stack empty check bhool jaana
- Closing bracket types ka matching galat karna
Practice questions
- Valid parentheses implement karo
- Minimum parentheses add/remove to make valid solve karo