2019-11-10 LeetCode in Rust LeetCode 678. Valid Parenthesis String Problem Statement impl Solution { fn check(s: &String, start: usize, c: i32) -> bool { let mut count = c; if count < 0 { return false; } for i in start..s.len() { let c = s.chars().nth(i).unwrap(); if c == '(' { count += 1; } else if c == ')' { if count <= 0 { return false; } count -= 1; } else if c == '*' { return Self::check(s, i + 1, count + 1) || Self::check(s, i + 1, count - 1) || Self::check(s, i + 1, count); } } return count == 0; } pub fn check_valid_string(s: String) -> bool { return Self::check(&s, 0, 0); }} Newer LeetCode 660. Remove 9 Older LeetCode 704. Binary Search