java版本
采用递归的方式解决问题
贴大佬的代码,后附个人理解
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
str = str.replace("[", "("); // 将括号统一为小括号
str = str.replace("]", ")");
str = str.replace("{", "(");
str =