Company: GigSky
Difficulty: medium
Vending Machine Restocking Picture yourself as a technician in charge of restocking N vending machines set out along a single corridor. The machines are lined up and numbered from 0 to N-1, with the i th machine sitting at x = i. Your supply cart starts at x = -1, the only place where it can be topped up. Each machine needs a different quantity of stock, and you must service them strictly left to right. If your cart runs out partway through restocking a machine, you must wheel it back to x = -1 and refill it before moving on to the next machine. The cart may only be refilled once it is completely empty and unable to fully cover the next machine's need — never earlier. Moving one unit along the corridor costs exactly one step. Work out the total number of steps you must walk to finish restocking every machine along the corridor. Notes You begin at position -1. Machine numbering begins at 0. Function Description Complete the function solution() provided in the editor. The function takes