Skip to content

Commit 3bf782e

Browse files
authored
Update score-of-parentheses.py
1 parent b88abff commit 3bf782e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Python/score-of-parentheses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def scoreOfParentheses(self, S):
4747
depth += 1
4848
else:
4949
depth -= 1
50-
if S[i] == '(' and S[i+1] == ')':
51-
result += 2**(depth-1)
50+
if S[i-1] == '(':
51+
result += 2**depth
5252
return result
5353

5454

0 commit comments

Comments
 (0)