-
-
Notifications
You must be signed in to change notification settings - Fork 299
/
1111.py
28 lines (25 loc) · 886 Bytes
/
1111.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
__________________________________________________________________________________________________
class Solution:
def maxDepthAfterSplit(self, seq: str) -> List[int]:
a = 0
b = 0
n = len(seq)
ans = [0] * n
for i, c in enumerate(seq):
if c == '(':
if a < b:
a += 1
ans[i] = 0
else:
b += 1
ans[i] = 1
else:
if a < b:
b -= 1
ans[i] = 1
else:
a -= 1
ans[i] = 0
return ans
__________________________________________________________________________________________________
__________________________________________________________________________________________________