There was an error while loading. Please reload this page.
1 parent 2ebd4e5 commit 9cbfdbaCopy full SHA for 9cbfdba
1 file changed
Hongjoo/lv2/올바른괄호.py
@@ -0,0 +1,28 @@
1
+def solution(s):
2
+ answer = True
3
+ print(s)
4
+ #1. s은 ( 로 시작, ) 가 끝
5
+ if s[0] == ")":
6
+ answer = False
7
+ return answer
8
+ elif s[-1] == "(":
9
10
11
+ #2.) 와 (의 개수 동일
12
+ left = 0
13
+ right = 0
14
+ for n in s :
15
+ if n == "(":
16
+ left +=1
17
+ elif n == ")":
18
+ right +=1
19
+ else:
20
21
22
+
23
+ if left != right :
24
25
26
27
28
+ return True
0 commit comments