205. Longest Valid Parentheses
HardStack
Print the length of the longest valid (well-formed) parentheses substring.
Input format
A single line of ( and ) (it may be empty).
Output format
The length.
Example 1
Input
(()
Output
2
Example 2
Input
)()())
Output
4
Constraints
0 ≤ length ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…