data_structures.stacks.balanced_parentheses

Attributes

examples

Functions

balanced_parentheses(→ bool)

Use a stack to check if a string of parentheses is balanced.

Module Contents

data_structures.stacks.balanced_parentheses.balanced_parentheses(parentheses: str) bool

Use a stack to check if a string of parentheses is balanced. >>> balanced_parentheses(“([]{})”) True >>> balanced_parentheses(“[()]{}{[()()]()}”) True >>> balanced_parentheses(“[(])”) False >>> balanced_parentheses(“1+2*3-4”) True >>> balanced_parentheses(“”) True

data_structures.stacks.balanced_parentheses.examples = ['((()))', '((())', '(()))']