Tap here to switch tabs
Problem
Submissions

Problem: Find All Possible Stable Binary Arrays II

Find All Possible Stable Binary Arrays II asks you to count binary arrays with zero and one counts. Subarrays longer than the limit must contain both values. Return the count modulo a large prime.

Statement

Given three positive integers zero, one, and limit.

A binary array arr is considered stable if:

  • The number of occurrences of 00 in arr is exactly zero.

  • The number of occurrences of 11 in arr is exactly one.

  • Every contiguous subarray of arr with a length strictly greater than limit contains at least one 00 and at least one 11.

Return the total number of stable binary arrays. Since the answer can be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq zero, one, limit ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find All Possible Stable Binary Arrays II

Find All Possible Stable Binary Arrays II asks you to count binary arrays with zero and one counts. Subarrays longer than the limit must contain both values. Return the count modulo a large prime.

Statement

Given three positive integers zero, one, and limit.

A binary array arr is considered stable if:

  • The number of occurrences of 00 in arr is exactly zero.

  • The number of occurrences of 11 in arr is exactly one.

  • Every contiguous subarray of arr with a length strictly greater than limit contains at least one 00 and at least one 11.

Return the total number of stable binary arrays. Since the answer can be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq zero, one, limit ≤1000\leq 1000