leetle

Daily challenge for 2026-11-17

686. Minimal Energy Flight Hops

A solar-powered drone travels across a series of charging platforms positioned along a straight route. The drone starts at platform 0 and aims to reach the final platform n - 1.

You are given an array of non-negative integers battery of length n, where battery[i] represents the maximum number of platforms forward the drone can jump from platform i. However, each hop incurs an energy penalty equal to the index difference of that hop squared: jumping from platform i to platform j (where i < j <= i + battery[i]) costs (j - i) * (j - i).

Return the minimum total energy penalty required to reach the last platform. If platform n - 1 cannot be reached, return -1.

Assumptions:
- 1 <= battery.length <= 1000
- 0 <= battery[i] <= 1000

Example:
Input: {"battery": [2, 3, 1, 1, 4]}
Output: 4

Run this challenge interactively in Python or JavaScript when the app loads.