Valid Parethesis
https://leetcode.com/problems/valid-parenthesis-string/
class Solution:
def checkValidString(self, s: str) -> bool:
cmin = 0
cmax = 0
for i in s:
if i == "(":
cmax+=1
cmin+=1
elif i == ")":
cmax-=1
cmin = max(cmin-1,0)
elif i == "*":
cmax+=1
cmin = max(cmin-1,0)
if cmax < 0:
return False
return cmin == 0Last updated