Skip to content

Commit 9cdb015

Browse files
Time: 3258 ms (24.57%) | Memory: 29.6 MB (93.66%) - LeetSync
1 parent 044d54b commit 9cdb015

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def countStableSubsequences(self, nums: List[int]) -> int:
3+
e1 = 0
4+
e2 = 0
5+
o1 = 0
6+
o2 = 0
7+
8+
for num in nums:
9+
if num % 2 == 0:
10+
e2 += e1
11+
e1 += 1 + o1 + o2
12+
else:
13+
o2 += o1
14+
o1 += 1 + e1 + e2
15+
16+
return (e1 + e2 + o1 + o2) % (10 ** 9 + 7)

0 commit comments

Comments
 (0)