-Code
import java.util.*;
class Solution
{
public int solution(String s)
{
Stack<String> deq = new Stack<>();
for (String ss : s.split("")) {
if (!deq.isEmpty() && deq.peek().equals(ss)) {
deq.pop();
continue;
}
deq.add(ss);
}
return deq.isEmpty() ? 1: 0;
}
}
'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
[프로그래머스/Java] N개의 최소공배수 (0) | 2025.03.01 |
---|---|
[프로그래머스/Java] 영어 끝말잇기 (0) | 2025.02.28 |
[프로그래머스/Java] 피보나치 수 (0) | 2025.02.28 |
[프로그래머스/Java] 다음 큰 숫자 (0) | 2025.02.28 |
[프로그래머스/Java] 숫자의 표현 (0) | 2025.02.28 |