We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d10c353 commit f3bbf04Copy full SHA for f3bbf04
1 file changed
live9/test99/문제3/백유진.py
@@ -0,0 +1,26 @@
1
+def solution(s):
2
+ answer = 0
3
+
4
+ for i in range(len(s)):
5
+ ns = s[i:] + s[:i]
6
7
+ stack = []
8
+ isValid = True
9
10
+ for n in ns:
11
+ if n == '(' or n == '{' or n == '[':
12
+ stack.append(n)
13
+ else:
14
+ if not stack:
15
+ isValid = False
16
+ break
17
+ top = stack[-1]
18
+ if n == ')' and top == '(' or n == '}' and top == '{' or n == ']' and top == '[':
19
+ stack.pop()
20
21
22
23
+ if isValid and not stack:
24
+ answer += 1
25
26
+ return answer
0 commit comments