longest-valid-parentheses, using stack to maintain unmatched left parentheses indices, also keep track of the indices of unmatched right parentheses