Opening your workspace…
Workspace/Coding room
Opening your workspace…
At dawn, a goose lays a row of golden eggs on the castle steps. The royal baker must carry them to the vault in order, but each basket can hold only so much weight. Help the baker find the fewest baskets needed, keeping each basket’s eggs together in a consecutive stretch of the row.
[2,3,1,2,4,2], 6Output3Pack [2, 3, 1], then [2, 4], then [2].
[5,5,5], 5Output3Each egg needs its own basket.
Keep filling the current basket until the next egg would exceed its capacity.
function solve(weights, capacity) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.