Sign in

Find the longest sequence of multiple Parentheses

Problem statement: Given a string s consisting of open and closed brackets "(" and ")", return the length of the longest substring in s that is a valid string of parentheses.

Example 1




"(())" is the longest substring with valid parentheses.

Naive approach: Find all the substrings of a given string. For every string, check…