Find All Possible Stable Binary Arrays II
You are given 3 positive integers zero, one, and limit.
You are given 3 positive integers zero, one, and limit.
A binary array arr is called stable if:
Return the total number of stable binary arrays.
Since the answer may be very large, return it modulo 10^9 + 7.
Example 1
Input: zero = 1, one = 1, limit = 2
Output: 2
Explanation: The two possible stable binary arrays are [1,0] and [0,1] .
Example 2
Input: zero = 1, one = 2, limit = 1
Output: 1
Explanation: The only possible stable binary array is [1,0,1] .
Example 3
Input: zero = 3, one = 3, limit = 2
Output: 14
Explanation: 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] .
Constraints
- 1 <= zero, one, limit <= 1000
Hints
Companies
No companies reported yet.
Discussion
Sign in to join the discussion.
Loading discussion...
Test results
No test cases yet.