Algorithm · Point72 · Hard
Alex is visiting n houses placed in a row, beginning at house 0 with an initial energy of initialEnergy. At every house i, there are two resources: energy[i] units of energy and coins[i] coins. Alex must travel to the houses sequentially, without skipping any, and can decide to stop at any point. At each house, Alex has to pick exactly one of the following actions: Take the energy: add energy[i] to the current energy pool. Take the coins: add coins[i] to the collected coin…
Checking your access…