301. Remove Invalid Parentheses Hard

@problem@discussion
#String#Backtracking#Breadth-First Search



1/**
2 * [301] Remove Invalid Parentheses
3 *
4 * Given a string s that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid.
5 * Return all the possible results. You may return the answer in any order.
6 *  
7 * Example 1:
8 * 
9 * Input: s = "()())()"
10 * Output: ["(())()","()()()"]
11 * 
12 * Example 2:
13 * 
14 * Input: s = "(a)())()"
15 * Output: ["(a())()","(a)()()"]
16 * 
17 * Example 3:
18 * 
19 * Input: s = ")("
20 * Output: [""]
21 * 
22 *  
23 * Constraints:
24 * 
25 * 	1 <= s.length <= 25
26 * 	s consists of lowercase English letters and parentheses '(' and ')'.
27 * 	There will be at most 20 parentheses in s.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/remove-invalid-parentheses/
33// discuss: https://leetcode.com/problems/remove-invalid-parentheses/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn remove_invalid_parentheses(s: String) -> Vec<String> {
39        vec![]
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_301() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.