mediumDynamic ProgrammingGreedyStackString 0 views

Valid Parenthesis String

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

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

The following rules define a valid string:

Valid Parenthesis String diagram

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 '*'.

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.