Search

비밀 노트

후위 표기식
Before
for (int i = 0; i < N; i++) { Stack<Character> stack = new Stack<>(); String input = br.readLine(); for (char ch : input.toCharArray()) { if (stack.isEmpty()) { stack.push(ch); continue; } if (stack.peek() == ch) { stack.pop(); } }
Java
복사
After
for (int i = 0; i < N; i++) { Stack<Character> stack = new Stack<>(); String input = br.readLine(); for (char ch : input.toCharArray()) { if (!stack.isEmpty() && stack.peek() == ch) { stack.pop(); } else { stack.push(ch); } }
Java
복사