Question bank › Stack
Dsa Stack Hard

Balancing Brackets in a Document

You are given a string representing a document where some characters are brackets: '(', ')', '{', '}', '[' and ']'. Your task is to confirm whether the brackets in the document are balanced. A sequence of brackets is considered balanced if they are properly closed and nested. Implement a function that reads the input string and outputs 'True' if the document is balanced, 'False' otherwise. Input Format: - A single string containing the document. Output Format: - 'True' or 'False'. Example: Input: {[()]} Output: True

Key concepts

stackvalidationstring

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.