File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -2186,6 +2186,46 @@ Put the code below in main.rs and run `cargo run`
21862186 println! (" result: {}" , result );
21872187```
21882188
2189+ # 678. Valid Parenthesis String
2190+
2191+ ## Description
2192+
2193+ Given a string s containing only three types of characters: '(', ')' and '* ', return true if s is valid.
2194+
2195+ The following rules define a valid string:
2196+
2197+ - Any left parenthesis '(' must have a corresponding right parenthesis ')'.
2198+ - Any right parenthesis ')' must have a corresponding left parenthesis '('.
2199+ - Left parenthesis '(' must go before the corresponding right parenthesis ')'.
2200+ - '* ' could be treated as a single right parenthesis ')' or a single left parenthesis '(' or an empty string "".
2201+
2202+ ## Examples
2203+
2204+ ``` text
2205+ Example 1:
2206+
2207+ Input: s = "()"
2208+ Output: true
2209+ Example 2:
2210+
2211+ Input: s = "(*)"
2212+ Output: true
2213+ Example 3:
2214+
2215+ Input: s = "(*))"
2216+ Output: true
2217+ ```
2218+
2219+ ## How to Run in main.rs
2220+
2221+ Put the code below in main.rs and run ` cargo run `
2222+
2223+ ``` rust
2224+ let s = String :: from (" (*))" );
2225+ let result = leetcode :: medium :: valid_parenthesis_string :: check_valid_string (s );
2226+ println! (" result: {}" , result );
2227+ ```
2228+
21892229# 695. Max Area of Island
21902230
21912231## Description
You can’t perform that action at this time.
0 commit comments