A dashboard builder lets you place exactly three widgets side by side in a row that is rowWidth pixels wide. The available widgets have the widths in widths.
Write fillingTriples(widths, rowWidth) that returns every choice of three different widgets whose widths add up to exactly rowWidth, as index triples [i, j, k] with i < j < k.
Return the triples sorted: by i, then by j, then by k. Return [] if there are none.
Input: widths = [100,150,250,50,200], rowWidth = 500 Output: [[0,1,2],[2,3,4]]
100 + 150 + 250 and 250 + 50 + 200 both make 500; no other triple does.
Input: widths = [10,10,10,10], rowWidth = 30 Output: [[0,1,2],[0,1,3],[0,2,3],[1,2,3]]
Any three of the four widgets fit.
0 <= widths.length <= 1001 <= widths[i] <= 20001 <= rowWidth <= 6000Run 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 #7 Three Widgets Fill the 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.