Dsa
Stack
Medium
Expression Validation with Nested Operators
You are given a string representation of a mathematical expression containing integers, operators ('+', '-', '*', '/'), and parentheses. Your task is to validate whether the expression is correct in terms of syntax (correct nesting of operators and parentheses).
Input:
A single line string containing the expression to validate. The length will be between 1 and 10000 characters.
Output:
'Valid' if the expression is valid, otherwise 'Invalid'.
Example:
Input:
(3 + (4 - 5)) * 2
Output:
Valid
Key concepts
stackexpressionvalidation
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