0 out of 464 challenges solved
Write a Python function `check_expression(expression: str) -> bool` that checks if the given string `expression` has balanced parentheses. The function should return `True` if the parentheses are balanced and `False` otherwise. The expression may contain the following types of parentheses: `()`, `{}`, and `[]`. #### Example Usage ```python [main.nopy] check_expression("{()}[{}]") # True check_expression("{()}[{]") # False check_expression("{()}[{}][]({})") # True ``` #### Constraints - The input string will only contain the characters `(){}[]`. - An empty string is considered balanced.
from collections import deque def check_expression(expression: str) -> bool: """ Check if the given expression has balanced parentheses. Args: expression (str): The input string containing parentheses. Returns: bool: True if the parentheses are balanced, False otherwise. """ # Initialize a stack to keep track of opening parentheses stack = deque() # Iterate through each character in the expression for char in expression: # Placeholder for implementation pass # Placeholder for final check return False