Opening your workspace…
Workspace/Coding room
Opening your workspace…
Give Anya a peanut before she blurts out one of Papa’s thoughts and blows his cover. Loid’s mission notes list the minutes when she’ll overhear a secret. A peanut given at the start of minute m keeps her busy chewing from minute m through minute m + chewMinutes − 1, inclusive. What’s the fewest peanuts Loid needs to pack to keep every secret quiet?
[2,3,5,6,9], 4Output2A peanut at minute 2 covers secrets at 2, 3, and 5. A second at minute 6 covers 6 and 9. One peanut cannot cover both 2 and 9.
[4,7,10], 3Output3The peanut at minute 4 lasts through minute 6. Each secret arrives just as Anya finishes chewing, so she needs a fresh peanut at 7 and again at 10.
Start chewing on the earliest uncovered secret.
function solve(secretMinutes, chewMinutes) { // 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.