ByteByteGo logo
menuProblems List

Valid Parenthesis Expression

Easy

Given a string representing an expression of parentheses containing the characters '(', ')', '[', ']', '{', or '}', determine if the expression forms a valid sequence of parentheses.

A sequence of parentheses is valid if every opening parenthesis has a corresponding closing parenthesis, and no closing parenthesis appears before its matching opening parenthesis.

Example 1:

Input: s = '([]{})'
Output: True

Example 2:

Input: s = '([]{)}'
Output: False

Explanation: The '(' parenthesis is closed before its nested '{' parenthesis is closed.

You can practice coding exercises online by logging into bytebytego.com on your laptop.