# ★☆☆☆☆ 짝지어 제거하기

# 구현코드

import java.util.Stack;

public class Solution {
    public int solution(String s) {
        Stack<Integer> stack = new Stack<>();
        for (int i = 0; i < s.length(); i++) {
            if(stack.isEmpty()){
                stack.add(s.charAt(i)-'0');
                continue;
            }

            int front = stack.pop();
            int back = s.charAt(i) -'0';

            if(front == back)
                continue;
            stack.add(front);
            stack.add(back);
        }

        if (stack.isEmpty())
            return 1;
        return 0;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25