A grid system has rows total columns wide. Cards come in a few allowed widths, listed in widths, and a row is filled from left to right with cards whose widths add up to exactly total. Any width may be used many times, and the order matters: a 1-wide card followed by a 2-wide card is a different row from a 2 followed by a 1.
Write countRowLayouts(widths, total) that returns how many different rows are possible, modulo 1000000007.
Input: widths = [1,2], total = 3 Output: 3
1 + 1 + 1, 1 + 2, and 2 + 1.
Input: widths = [3,4], total = 5 Output: 0
No mix of 3 and 4 makes 5.
1 <= widths.length <= 501 <= widths[i] <= 1000, all different1 <= total <= 1000Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #519 Ordered Card Widths for a Row. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.