3130. Find All Possible Stable Binary Arrays II Hard
1/**
2 * [3130] Find All Possible Stable Binary Arrays II
3 *
4 * You are given 3 positive integers zero, one, and limit.
5 * A <span data-keyword="binary-array">binary array</span> arr is called stable if:
6 *
7 * The number of occurrences of 0 in arr is exactly zero.
8 * The number of occurrences of 1 in arr is exactly one.
9 * Each <span data-keyword="subarray-nonempty">subarray</span> of arr with a size greater than limit must contain both 0 and 1.
10 *
11 * Return the total number of stable binary arrays.
12 * Since the answer may be very large, return it modulo 10^9 + 7.
13 *
14 * <strong class="example">Example 1:
15 * <div class="example-block">
16 * Input: <span class="example-io">zero = 1, one = 1, limit = 2</span>
17 * Output: <span class="example-io">2</span>
18 * Explanation:
19 * The two possible stable binary arrays are [1,0] and [0,1].
20 * </div>
21 * <strong class="example">Example 2:
22 * <div class="example-block">
23 * Input: <span class="example-io">zero = 1, one = 2, limit = 1</span>
24 * Output: <span class="example-io">1</span>
25 * Explanation:
26 * The only possible stable binary array is [1,0,1].
27 * </div>
28 * <strong class="example">Example 3:
29 * <div class="example-block">
30 * Input: <span class="example-io">zero = 3, one = 3, limit = 2</span>
31 * Output: <span class="example-io">14</span>
32 * Explanation:
33 * All the possible stable binary arrays are [0,0,1,0,1,1], [0,0,1,1,0,1], [0,1,0,0,1,1], [0,1,0,1,0,1], [0,1,0,1,1,0], [0,1,1,0,0,1], [0,1,1,0,1,0], [1,0,0,1,0,1], [1,0,0,1,1,0], [1,0,1,0,0,1], [1,0,1,0,1,0], [1,0,1,1,0,0], [1,1,0,0,1,0], and [1,1,0,1,0,0].
34 * </div>
35 *
36 * Constraints:
37 *
38 * 1 <= zero, one, limit <= 1000
39 *
40 */
41pub struct Solution {}
42
43// problem: https://leetcode.com/problems/find-all-possible-stable-binary-arrays-ii/
44// discuss: https://leetcode.com/problems/find-all-possible-stable-binary-arrays-ii/discuss/?currentPage=1&orderBy=most_votes&query=
45
46// submission codes start here
47
48impl Solution {
49 pub fn number_of_stable_arrays(zero: i32, one: i32, limit: i32) -> i32 {
50 0
51 }
52}
53
54// submission codes end
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn test_3130() {
62 }
63}
64
Back
© 2025 bowen.ge All Rights Reserved.