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
- 1 <= s.length <= 100
- s[i] is '(', ')' or '*'.
Starter code (python)
class Solution(object):
def checkValidString(self, s):
"""
:type s: str
:rtype: bool
"""
Related problems
- Longest Substring Without Repeating Characters (Medium)
- Longest Palindromic Substring (Medium)
- Container With Most Water (Medium)
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.