Zepruv › Coding problems

Valid Parenthesis String

Medium · String, Dynamic Programming, Stack, Greedy

Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid.
The following rules define a valid string:

Example 1

Input: s = "()"
Output: true

Example 2

Input: s = "(*)"
Output: true

Example 3

Input: s = "(*))"
Output: true

Constraints

Starter code (python)

class Solution(object):
    def checkValidString(self, s):
        """
        :type s: str
        :rtype: bool
        """
        

Related problems

Previous: Longest Continuous Increasing Subsequence · Next: Repeated String Match · All problems

Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.