Maximum Nesting Depth of Two Valid Parentheses Strings LeetCode solution in Python

1
class Solution:
2
def maxDepthAfterSplit(self, seq: str) -> List[int]:
3
ans = []
4
last = 1
5
for i in seq:
6
if i == "(":
7
if last == 0:
8
ans.append(1)
9
else:
10
ans.append(0)
11
else:
12
ans.append(last)
13
last = (last + 1) % 2
14
return ans

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0