Valid Parenthesis String

Given a string s containing only '(', ')' and '*', return true if s is valid. A valid string must have balanced parentheses, and '*' can be treated as '(', ')' or an empty string.

Constraints

  • 1 <= s.length <= 100
  • s[i] is '(', ')' or '*'
Saving… · 2 lines
class Solution:
def isValidParenthesisString(self, s: str) -> bool:
Console

Click Run to execute sample tests.