We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 963cdbd + ac318e5 commit 055b0d9Copy full SHA for 055b0d9
LiiNi-coder/202510/28 PGM 괄호 회전하기.md
@@ -0,0 +1,34 @@
1
+```java
2
+import java.util.*;
3
+class Solution {
4
+ public int solution(String s) {
5
+ char[] cs = s.toCharArray();
6
+ int answer = 0;
7
+ Deque<Character> q = new ArrayDeque<Character>();
8
+ for(int i = 0; i<s.length(); i++){
9
+ q = new ArrayDeque<Character>();
10
+ for(int d = 0; d<s.length(); d++){
11
+
12
+ int id = (i+d) % s.length();
13
+ char now = cs[id];
14
+ Character pre = q.peekLast();
15
+ if(pre == null){
16
+ q.offer(now);
17
+ }
18
+ else if(pre == '(' && now == ')'){
19
+ q.pollLast();
20
+ }else if(pre == '{' && now == '}'){
21
22
+ }else if(pre == '[' && now == ']'){
23
24
+ }else{
25
26
27
28
+ if(q.size() ==0)answer++;
29
30
31
+ return answer;
32
33
+}
34
+```
0 commit comments