See More

package swea.stack2; import java.util.Scanner; import java.util.Stack; public class Solution1224 { static int n; static String s, ns; static char c; public static void main(String[] args) { Scanner sc = new Scanner(System.in); Stack st = new Stack<>(); Stack num = new Stack<>(); for (int i = 0; i < 10; i++) { n = sc.nextInt(); s = sc.next(); ns = ""; for (int j = 0; j < s.length(); j++) { c = s.charAt(j); if (0 <= c - 48 && c - 48 < 10) { ns += c; }else{ if(st.isEmpty()){ st.push(c); }else{ if(c == '(') { st.push(c); } else if (c == ')') { while (st.peek() != '(') { ns += st.pop(); } st.pop(); } else if (check(st.peek())<=check(c)){ st.push(c); }else{ while(!st.isEmpty() && check(c)