Question:codility Lesson7 Nesting
My Answer:
def solution(S):
if len(S) % 2 == 1:
return 0
num = 0
for ele in S:
if ele == "(":
num += 1
else:
num -= 1
if num < 0:
return 0
if num == 0:
return 1
else:
return 0