Back to course home
0% completed
Valid Parentheses (easy)
Problem Statement
Determine if an input string containing only the characters '(', ')', '{', '}', '[', and ']' is valid. A string is considered valid if:
- Open brackets must be closed by the same type of brackets.
- Open brackets must be closed in the correct order.
- Each close bracket has a corresponding open bracket of the same type.
Examples
-
- Input:
"(]"
- Expected Output:
false
- Justification: The opening parenthesis '(' is not closed by its corresponding closing parenthesis.
- Input:
-
- Input:
"{[]}"
- Expected Output:
true
- Input:
.....
.....
.....
Like the course? Get enrolled and start learning!