Tap here to switch tabs
Problem
Submissions

Problem: Number of Stable Subsequences

med
30 min
Try to solve the Number of Stable Subsequences problem.

Statement

Given an integer array nums, return the total number of stable subsequences.

A subsequence of an array nums is considered stable if it is non empty and does not contain 33 consecutive elements with the same parity (that is, it does not contain 33 consecutive even integers or 33 consecutive odd integers).

Note: A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Stable Subsequences

med
30 min
Try to solve the Number of Stable Subsequences problem.

Statement

Given an integer array nums, return the total number of stable subsequences.

A subsequence of an array nums is considered stable if it is non empty and does not contain 33 consecutive elements with the same parity (that is, it does not contain 33 consecutive even integers or 33 consecutive odd integers).

Note: A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5