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.Q5397; 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 n = Integer.parseInt(br.readLine()); while (n-- > 0) { Stack<Character> left = new Stack<>(); Stack<Character> right = new Stack<>(); String input = br.readLine(); for (int i = 0; i < input.length(); i++) { if (input.charAt(i) == '<') { if (!left.isEmpty()) right.push(left.pop()); } else if (input.charAt(i) == '>') { if (!right.isEmpty()) left.push(right.pop()); } else if (input.charAt(i) == '-') { if (!left.isEmpty()) left.pop(); } else { left.push(input.charAt(i)); } } StringBuilder sb = new StringBuilder(); while (!left.isEmpty()) { right.push(left.pop()); } while (!right.isEmpty()) { sb.append(right.pop()); } System.out.println(sb.toString()); } } }
The text was updated successfully, but these errors were encountered:
0d11f5c
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
The text was updated successfully, but these errors were encountered: