Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Valid Parentheses

XPChallenge Points: 10
levelLevel: Easy

You are given a string s containing only the characters '(', ')', '{', '}', '[', and ']'.
Your task is to determine whether the input string is valid.
A string is considered valid if:
1. Every opening bracket has a corresponding closing bracket of the same type.
2. Brackets are closed in the correct order.
3. No unmatched or improperly nested brackets exist.
Use a stack-based approach to check for validity.

Example 1:

Input: s = "{[()]}"

Output: true

Example 2:

Input: s = "{[(])}"

Output: false

Example 3:

Input: s = "((({[]})))"

Output: true

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result