DeepSeek LeetCode 3686. 稳定子序列的数量 Python3实现
python
class Solution:def countStableSubsequences(self, nums: List[int]) -> int:MOD 10**9 7# dp[p][c]:# p: 0偶数, 1奇数# c: 0末尾连续长度为1, 1末尾连续长度为2dp [[0, 0] for _ in range(2)]for num in nums:p num & 1 # 当前元素的奇偶性q p ^ 1 #…
2026/7/24 19:24:07