Your question is Balanced Brackets Validation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
NetApp ONTAP configuration and access expressions can contain nested grouping symbols alongside identifiers, operators, and whitespace. Implement a validator that determines whether every bracket is correctly opened, nested, and closed.
Given a string expression, return True if all parentheses (), square brackets [], and curly braces {} are balanced. Ignore all characters that are not brackets. A closing bracket is valid only when it matches the most recently opened unmatched bracket.
The input is a string, and the output is a Boolean. An empty string or a string containing no brackets is balanced.
def is_balanced(expression):