678. Valid Parenthesis String Medium
1/**
2 * [678] Valid Parenthesis String
3 *
4 * Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid.
5 * The following rules define a valid string:
6 *
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 *
12 *
13 * Example 1:
14 * Input: s = "()"
15 * Output: true
16 * Example 2:
17 * Input: s = "(*)"
18 * Output: true
19 * Example 3:
20 * Input: s = "(*))"
21 * Output: true
22 *
23 * Constraints:
24 *
25 * 1 <= s.length <= 100
26 * s[i] is '(', ')' or '*'.
27 *
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/valid-parenthesis-string/
32// discuss: https://leetcode.com/problems/valid-parenthesis-string/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37 pub fn check_valid_string(s: String) -> bool {
38 false
39 }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_678() {
50 }
51}
52
Back
© 2025 bowen.ge All Rights Reserved.