Skip to content

Commit 5af56b4

Browse files
committed
[level 2] Title: 짝지어 제거하기, Time: 87.64 ms, Memory: 65.3 MB -BaekjoonHub
1 parent 5936c43 commit 5af56b4

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

프로그래머스/2/12973. 짝지어 제거하기/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 14.8 MB, 시간: 144.24 ms
7+
메모리: 65.3 MB, 시간: 87.64 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2024년 2월 1일 21:36:5
19+
2025년 06월 02일 21:17:49
2020

2121
### 문제 설명
2222

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.*;
2+
3+
class Solution
4+
{
5+
static Stack<Character> stack = new Stack<>();
6+
7+
public int solution(String s)
8+
{
9+
10+
for(char c : s.toCharArray()){
11+
if(stack.isEmpty()){ //스택 비어있으면 그냥 push
12+
stack.push(c);
13+
}else if(stack.peek().equals(c)){ //스택 맨 위의 값이 현재값과 같으면 pop
14+
stack.pop();
15+
}else{
16+
stack.push(c); //스택 맨 위의 값이 현재값과 다르면 push
17+
}
18+
}
19+
20+
return stack.isEmpty() ? 1 : 0;
21+
}
22+
}

0 commit comments

Comments
 (0)