leetle

Daily challenge for 2026-10-07

645. Route Battery Mileage Check

You are monitoring an electric delivery scooter. You are given an array of integers segments where positive numbers represent miles driven under battery power, negative numbers represent miles gained from regenerative braking downhill, and zero represents idling.

Return the total net battery miles consumed (sum of positive segments minus regenerative miles) only from segments where battery consumption or regeneration actually occurred, ignoring idle segments. If the resulting net miles are less than 0, return 0 as the battery cannot charge past full capacity.

Example:
Input: segments = [5, -2, 0, 4]
Output: 7

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