Easy Python Solution: No Dynamic Programming
\tclass Solution(object):\n\t\tdef longestValidParentheses(self, s):\n\t\t\t"""\n\t\t\t:type s: str\n\t\t\t:rtype: int\n\t\t\t"""\n\t\t\tm = l = r = 0\n\t\t\tfo
\tclass Solution(object):\n\t\tdef longestValidParentheses(self, s):\n\t\t\t"""\n\t\t\t:type s: str\n\t\t\t:rtype: int\n\t\t\t"""\n\t\t\tm = l = r = 0\n\t\t\tfor e in s:\n\t\t\t\tif e==\'(\':\n\t\t\t\t\tl+=1\n\t\t\t\telse:\n\t\t\t\t\tr+=1\n\t\t\t\tif l==r:\n\t\t\t\t\tm = max(m,r+l)\n\t\t\t\telif r>l:\n\t\t\t\t\tl=r=0\n\t\t\tl=r=0\n\t\t\tfor e in s[::-1]:\n\t\t\t\tif e==\')\':\n\t\t\t\t\tr+=1\n\t\t\t\telse: \n\t\t\t\t\tl+=1\n\t\t\t\tif l==r: \n\t\t\t\t\tm=max(m,r+l)\n\t\t\t\telif l>r:\n\t\t\t\t\tl=r=0\n\t\t\treturn m\n
['Python', 'Python3']