2383. Minimum Hours of Training to Win a Competition Solution 1 (time O(n), space O(n)) class Solution(object): def minNumberOfHours(self, initialEnergy, initialExperience, energy, experience): """ :type initialEnergy: int :type initialExperience: int :type energy: List[int] :type experience: List[int] :rtype: int """ ans = 0 for t1, t2 in zip(energy, experience): if initialEnergy <= t1: ans += t1 - initialEnergy + 1 initialEnergy = t1 + 1 if initialExperience <= t2: ans += t2 - initialExperience + 1 initialExperience = t2 + 1 initialEnergy -= t1 initialExperience += t2 return ans