Add an O(n^2) solution to longest_valid_parentheses, got TLE.