Skip to content

Commit 17718c9

Browse files
authored
[20251014] PGM / Lv2 / 짝지어 제거하기 / 이강현
1 parent 09bfbb3 commit 17718c9

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+
class Solution
4+
{
5+
public int solution(String s)
6+
{
7+
int answer = -1;
8+
Stack<Character> stk = new Stack<>();
9+
10+
for(char c : s.toCharArray()){
11+
if(stk.isEmpty() || stk.peek() != c){
12+
stk.push(c);
13+
}else{
14+
stk.pop();
15+
}
16+
}
17+
18+
return stk.isEmpty() ? 1 : 0;
19+
}
20+
}
21+
```

0 commit comments

Comments
 (0)