comefrom: <doocs>0678.Valid Parenthesis String_1.py
code: def checkValidString( s: str) -> bool:
      n = len(s)
      left, asterisk = 0, 0
      for i in range(n):
          if s[i] == "(":
              left += 1
          elif s[i] == ")":
              if left > 0:
                  left -= 1
              elif asterisk > 0:
                  asterisk -= 1
              else:
                  return False
          else:
              asterisk += 1
      right, asterisk = 0, 0
      for i in range(n - 1, -1, -1):
          if s[i] == ")":
              right += 1
          elif s[i] == "(":
              if right > 0:
                  right -= 1
              elif asterisk > 0:
                  asterisk -= 1
              else:
                  return False
          else:
              asterisk += 1
      return True
masked: def sample_funcname ( var_0 : str ) -> bool :
      var_1 = len ( var_0 )
      var_2 , var_3 = 0 , 0
      for var_4 in range ( var_1 ) :
          if var_0 [ var_4 ] == "(" :
              var_2 += 1
          elif var_0 [ var_4 ] == ")" :
              if var_2 > 0 :
                  var_2 -= 1
              elif var_3 > 0 :
                  var_3 -= 1
              else :
                  return False
          else :
              var_3 += 1
      var_5 , var_3 = 0 , 0
      for var_4 in range ( var_1 - 1 , - 1 , - 1 ) :
          if var_0 [ var_4 ] == ")" :
              var_5 += 1
          elif var_0 [ var_4 ] == "(" :
              if var_5 > 0 :
                  var_5 -= 1
              elif var_3 > 0 :
                  var_3 -= 1
              else :
                  return False
          else :
              var_3 += 1
      return True
  