Valid Parenthesis String - Practice Coding | SlaveCode
Problems
Scratchpad
Run
Submit
0
0
1
2
3
4
5
6
7
8
9
0
0
1
2
3
4
5
6
7
8
9
:
0
0
1
2
3
4
5
6
7
8
9
0
0
1
2
3
4
5
6
7
8
9
Toggle theme (Current: Custom)
Scratchpad
Run
Submit
Description
Hints
Solutions
678. Valid Parenthesis String
Medium
30 Points
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:
Examples
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 '*'.
JAVASCRIPT
Code
Tests
Result
Description
Hints
Solutions
678. Valid Parenthesis String
Medium
30 Points
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:
Examples
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 '*'.
JAVASCRIPT
Code
Tests
Result