Skip to content

Commit e8eba8a

Browse files
authored
Update valid-parenthesis-string.py
1 parent 4d404d0 commit e8eba8a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Python/valid-parenthesis-string.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
# Given a string containing only three types of characters: '(', ')' and '*',
55
# write a function to check whether this string is valid. We define the validity of a string by these rules:
6+
# 1. Any left parenthesis '(' must have a corresponding right parenthesis ')'.
7+
# 2. Any right parenthesis ')' must have a corresponding left parenthesis '('.
8+
# 3. Left parenthesis '(' must go before the corresponding right parenthesis ')'.
9+
# 4. '*' could be treated as a single right parenthesis ')' or a single left parenthesis '(' or an empty string.
10+
# 5. An empty string is also valid.
611
#
7-
# Any left parenthesis '(' must have a corresponding right parenthesis ')'.
8-
# Any right parenthesis ')' must have a corresponding left parenthesis '('.
9-
# Left parenthesis '(' must go before the corresponding right parenthesis ')'.
10-
# '*' could be treated as a single right parenthesis ')' or a single left parenthesis '(' or an empty string.
11-
# An empty string is also valid.
1212
# Example 1:
1313
# Input: "()"
1414
# Output: True

0 commit comments

Comments
 (0)