Daily challenge for 2026-10-09
647. Fuel Efficiency Trip Ledger
You are given a list of non-negative integers distances representing individual trip segments in miles, and an integer mpg representing miles per gallon. For each segment where the distance is strictly greater than mpg, a bonus surcharge of 1 dollar is added. In addition, every completed trip of at least 1 mile incurs a base maintenance fee of 2 dollars (trips of 0 miles incur 0 dollars fee and no surcharge).
Return the total fee across all trips in distances.
Example:
Input: distances = [25, 40, 0, 15], mpg = 30
Output: 7
Explanation:
- Segment 25: base fee 2 (25 <= 30, no surcharge) = 2
- Segment 40: base fee 2 + surcharge 1 (40 > 30) = 3
- Segment 0: 0 miles = 0
- Segment 15: base fee 2 = 2
Total = 2 + 3 + 0 + 2 = 7.
Run this challenge interactively in Python or JavaScript when the app loads.