Billboard revenue

Write codeMedium14 minGoogle style

Your task

A highway agency sells billboard slots along a road, listed in order with the expected revenue for each (all positive). Local rules say two rented billboards must have at least two empty slots between them, so if you take slot i, the next one you take must be at index i+3 or later. Given the revenues, return the maximum total you can earn. An empty list returns 0. For example, [8, 3, 2, 9] gives 17 by taking slots 0 and 3.

Examples

max_billboard_revenue(revenues: list[int]) -> int
Example 1
Inputmax_billboard_revenue([8, 3, 2, 9])
Output17
Example 2
Inputmax_billboard_revenue([10, 1, 1, 1, 10])
Output20