Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Longest Valid Parentheses
Hard
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Given a string containing just parentheses, find the length of the longest valid parentheses substring.
Sample Input:
"(()"
Sample Output:
2
Hints
Hint 1
Use stack to track indices of parentheses
Hint 2
Push -1 as initial marker
Hint 3
Calculate length when finding matching pair
Code Editor
Reset
Run
Save
Loading...