def solution(efficiencies):
    current = efficiencies[0]
    maximum = efficiencies[0]

    for i in range(1, len(efficiencies)):
        current = max(efficiencies[i], current + efficiencies[i])
        maximum = max(maximum, current)

    return maximum


efficiencies = [-2, 1, -3, 4, -1, 2, 1, -5, 4]

print(solution(efficiencies))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: