Maximum LED panel output

Write codeMedium20 min

Your task

A stage lighting rig has one row of LED panels. Panel i cannot be driven past heat_caps[i], its heat limit, and every panel sits on a whole number of units from 0 upward. Two panels standing next to each other must not differ by more than max_step units or the seam between them looks harsh. Return the largest total the whole row can add up to. heat_caps may be empty, in which case the total is 0, and max_step may be 0. A panel with a low limit does not only hold down the panels to its right.

Examples

max_panel_brightness(heat_caps: list[int], max_step: int) -> int
Example 1
Inputmax_panel_brightness([10, 10, 1, 10, 10], 1)
Output11
Example 2
Inputmax_panel_brightness([4, 4, 4], 0)
Output12