Back to course home
0% completed
Solution: Longest Valid Parentheses
Problem Statement
You are given a string containing just the characters '(' and ')'. Your task is to find the length of the longest valid (well-formed) parentheses substring.
Example 1:
- Input:
"(())"
- Expected Output:
4
- Justification: The entire string is a valid parentheses substring.
Example 2:
- Input:
")()())"
- Expected Output:
4
- Justification: The longest valid parentheses substring is
"()()"
.
Example 3:
- Input:
"(()"
- Expected Output:
2
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible