We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main.java.com.poogle.BOJ.Q9012; 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)); int t = Integer.parseInt(br.readLine()); while (t-- > 0) { boolean flag = true; String line = br.readLine(); Stack<Character> stack = new Stack<>(); for (int i = 0; i < line.length(); i++) { char c = line.charAt(i); if (c == '(') { stack.push(c); } else if (c == ')') { if (!stack.isEmpty() && stack.pop() == '(') { continue; } else { flag = false; break; } } } if (!stack.isEmpty() || !flag) { System.out.println("NO"); } else { System.out.println("YES"); } } br.close(); } }
The text was updated successfully, but these errors were encountered:
32e66bd
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
The text was updated successfully, but these errors were encountered: