Longest Valid Parentheses
Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.
Longest Valid Parentheses

Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.

Example 1:
Input: "(()"
Output: 2
Input
arr ="(()"

Initialize stack with -1 as base index

(

0

(

1

)

2

Stack (indices)

-1

Index:

-1

Max Length:

0

Current

Valid

In Stack

Variables
No variables to display
DepthFunction Call
Stack empty
0/4