// Longest Valid Parentheses — HARD
// Category: stack
Given a string containing just the characters `'('` and `')'`, return the length of the longest valid (well-formed) parentheses substring.
Hint: Use a stack. Push indices of unmatched `'('`. When you see `')'`, pop from the stack — if empty, push the current index as the new base; otherwise, the current valid length is `i - stack.top()`.
Example: s = "(()"
Output: 2