Count how many binary arrays can be formed with fixed numbers of 0s and 1s while satisfying a stability condition on consecutive equal values.
Given two integers representing the number of 0s and 1s available, count how many binary arrays can be formed using exactly those values such that the array remains stable under the problem's constraint on runs of equal elements. Return the total number of valid arrays.
A valid solution should focus on counting arrangements rather than enumerating all possibilities explicitly.
The exact input format follows the platform's function signature.
Example 1
Input
zero = 1, one = 1, limit = 1
Output
2
Explanation
The valid arrays are [0,1] and [1,0].
Example 2
Input
zero = 2, one = 1, limit = 2
Output
3
Explanation
The valid arrays are [0,0,1], [0,1,0], and [1,0,0].
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.