Skip to content

Commit a37df16

Browse files
committed
Runtime: 4322 ms (Top 46.43%) | Memory: 18 MB (Top 47.62%)
1 parent 600066c commit a37df16

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
# Runtime: 4322 ms (Top 46.43%) | Memory: 18 MB (Top 47.62%)
12
class Solution:
23
def countSpecialSubsequences(self, nums: List[int]) -> int:
34
if not nums:
45
return 0
5-
6+
67
last_0 = 0
78
last_1 = 0
89
last_2 = 0
9-
10+
1011
for i in nums:
1112
if i == 0:
1213
last_0 = (2*last_0 + 1)% 1000000007
1314
elif i == 1:
1415
last_1 = (last_0 + 2*last_1) % 1000000007
1516
elif i == 2:
1617
last_2 = (last_1 + 2*last_2) % 1000000007
17-
return last_2 % 1000000007
18+
return last_2 % 1000000007

0 commit comments

Comments
 (0)