2383. Minimum Hours of Training to Win a Competition

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2383

class Solution:
    def minNumberOfHours(
        self,
        initialEnergy: int,
        initialExperience: int,
        energy: List[int],
        experience: List[int],
    ) -> int:
        res = max(0, sum(energy) - initialEnergy + 1)
        for x in experience:
            if initialExperience <= x:
                res += x - initialExperience + 1
                initialExperience = x + 1
            initialExperience += x
        return res