Given a string containing characters ( and ), find the length of the longest valid parentheses substring.
This problem asks for the length of the longest valid parentheses substring in a string made of '(' and ')'. A standard solution uses a stack to track unmatched indices, or dynamic programming to compute the longest valid length ending at each position. The key is handling matches and resets correctly while scanning the string in linear time.