Question bank › Strings
Dsa Strings Easy

Balanced Parentheses Sequence

You are given a string of parentheses and other characters (letters, digits, etc.). Write a program to check if the parentheses in the string are balanced. A string is balanced if every opening parenthesis has a corresponding closing parenthesis and they are in the correct order. Ignore all other characters in the string. Input Format: A single line of text containing the input string. Output Format: 'Balanced' if the parentheses are balanced, otherwise 'Not Balanced'. Example: Input: ab(c(d)e)f Output: Balanced

Key concepts

stringsstackvalidation

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.