better solution of longest-valid-parentheses