Skip to content

Commit 74fab70

Browse files
committed
p53
1 parent ca5489d commit 74fab70

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

53-multiple-bracket.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def MultipleBrackets(str):
2+
count = 0
3+
countList = []
4+
for i in str:
5+
if i == "(" or i == "[":
6+
count += 1
7+
countList.append(i)
8+
elif i == ")" or i == "]":
9+
if countList.pop() != ("(" if i == ")" else "["):
10+
return 0
11+
return "%d %d" %(1, count) if len(countList) == 0 else 0
12+
13+
# keep this function call here
14+
# to see how to enter arguments in Python scroll down
15+
print MultipleBrackets(raw_input())

0 commit comments

Comments
 (0)