Skip to content

Commit 7a5c7c5

Browse files
authored
[20260122] PGM / LV2 / 짝지어 제거하기 / 강신지
1 parent 7a70926 commit 7a5c7c5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
```java
2+
import java.util.*;
3+
4+
class Solution {
5+
public int solution(String s) {
6+
char[] arr = s.toCharArray();
7+
char[] stack = new char[arr.length];
8+
int top = 0;
9+
10+
for (char c : arr) {
11+
if (top > 0 && stack[top - 1] == c) {
12+
top--;
13+
} else {
14+
stack[top++] = c;
15+
}
16+
}
17+
18+
return top == 0 ? 1 : 0;
19+
}
20+
}
21+
```

0 commit comments

Comments
 (0)