Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may contain letters other than the parentheses ( and ). Example 1: Input: "()())()" Output: ["()()…
class Solution { public List<String> removeInvalidParentheses(String s) { List<String> ans = new ArrayList<>(); remove(s, ans, 0, 0, new char[]{'(', ')'}); return ans; } public void remove(String s, List<String> ans, int last_i, in…
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may contain letters other than the parentheses ( and ). Example 1: Input: "()())()" Output: ["()()…