Trains the technique from
LeetCode 3130Find All Possible Stable Binary Arrays IIThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A punch card is a single row of cells. Every cell is either a blank or a mark. A card is steady when all three hold:
zero blanks;one marks;limit + 1 cells in a row is all blanks or all marks.Two cards are different when some position carries a different kind of cell. Return how many steady cards exist, taken modulo 1000000007.
Example 1
With a cap of one, no two neighbouring cells may match. Only the card reading mark, blank, mark satisfies that while carrying one blank and two marks.
Example 2
A cap of one forces the kinds to alternate, so the card either opens with a blank or opens with a mark, giving two steady cards.
Example 3
Cards such as blank, blank, mark, blank, mark, mark are steady, since no three cells in a row match. Counting every such card gives this many.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def steady_layouts(zero: int, one: int, limit: int) -> int:public int steadyLayouts(int zero, int one, int limit)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.