File tree Expand file tree Collapse file tree 2 files changed +12
-15
lines changed
Expand file tree Collapse file tree 2 files changed +12
-15
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 10.1 MB, 시간: 196.77 ms
7+ 메모리: 9.23 MB, 시간: 200.20 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2024년 09월 18일 16:55:23
19+ 2025년 12월 27일 22:48:45
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 11def solution (s ):
22 cnt = 0
33 for i in range (len (s )):
4- x = (s + s [:i ])[i :]
5-
64 stack = []
7- for j in x :
8- if stack :
9- if j == ")" and stack [- 1 ] == "(" :
5+ for c in s :
6+ if not stack :
7+ stack .append (c )
8+ elif (stack [- 1 ] == '(' and c == ')' ) or \
9+ (stack [- 1 ] == '{' and c == '}' ) or \
10+ (stack [- 1 ] == '[' and c == ']' ):
1011 stack .pop ()
11- elif j == "}" and stack [- 1 ] == "{" :
12- stack .pop ()
13- elif j == "]" and stack [- 1 ] == "[" :
14- stack .pop ()
15- else :
16- stack .append (j )
1712 else :
18- stack .append (j )
19- if len ( stack ) == 0 :
13+ stack .append (c )
14+ if not stack :
2015 cnt += 1
16+ s = s [1 :] + s [0 ]
17+
2118 return cnt
You can’t perform that action at this time.
0 commit comments