#3686

Number of Stable Subsequences

expert · 1190 · lc hard +32 · 60.1% accepted · 84 likes · top 58%

Description

Given an integer array nums, a subsequence is stable when it has no three consecutive elements (within the subsequence) sharing the same parity. Count all stable subsequences and return the result modulo 109 + 7.

Code

1
2
3