题目及测试
package pid301;
/* Remove Invalid Parentheses
删除最小数量的无效括号,使得输入的字符串有效,返回所有可能的结果。
说明: 输入可能包含了除 ( 和 ) 以外的字符。
示例 1:
输入: "()())()"
输出: ["()()()", "(())()"]
示例 2:
输入: "(a)())()"
输出: ["(a)()()", "(a())()"]
示例 3:
输入: ")("
输出: [""]
*/
import java.util.List;
public class main {
public static void main(String[] args) {
String[] testTable = {"()())()","(a)())()",")("};
for (String ito : testTable) {
test(ito);
}
}
private static void test(String ito) {
Solution solution = new Solution();
List<String> rtn;
long begin = System.currentTimeMillis();
System.out.println("ito="+ito);
System.out.println();
//开始时打印数组
rtn= solution.removeInvalidParentheses(ito);//执行程序
long end = System.currentTimeMillis();
System.out.println("rtn=" );
for(i