Longest Valid Parentheses

Given a string that contains the characters '(' and ')', find the length of the longest valid parentheses substring.

Statement

Given a string that contains the characters '(' and ')', find the length of the longest valid parentheses substring.

Example

Let’s look at the image below:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.