Given an array arr, where each element represents the distance you can fly on the day. You start with k units of energy, which is also your maximum energy capacity. Each day, you can either:
- Fly: Use 1 unit of energy to fly
arr[i]distance. - Rest: Recover 1 unit of energy, up to the maximum of
k.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected