Valid Parenthesis String

Medium

Topics
StringGreedyDynamic ProgrammingStack

Given a string s containing only (, ) and *, return true if it can be made a valid parentheses string. A * can be treated as (, ), or an empty 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 consists of '(', ')' and '*'.
Run ⌘' · Submit ⌘⏎