class Solution(object):
def repeatedNTimes(self, S):
num = 0
tmp = S[0]
a = []
for i in range(len(S)):
if S[i] == "(":
tmp = "("
a.append("(")
elif tmp == "(" and S[i] == ")":
num += 2**(len(a)-1)
tmp = ")"
a.pop()
elif tmp == ")" and S[i] == ")":
a.pop()
return num
相关文章: