Python | Greedy | O(n)
Explained the variable names in code with comment.\n\n\nThe idea is to just greedily simulate the process.\n\nWhenever we don\'t have enough energy to move to t
Explained the variable names in code with comment.\n<hr />\n\nThe idea is to just greedily simulate the process.\n\nWhenever we don\'t have enough energy to move to the next stage, we add the minimum required to have +1 energy, and the same for experience.\n\nThen we add the experience from the current stage, and reduce the enery from the current stage as required by the problem.\n\nAt the end, we added X energy, and Y experience. So we return the sum, minus the initial starting values we had. \n```\nclass Solution:\n    def minNumberOfHours(self, initialEnergy: int, initialExperience: int, energy: List[int], experience: List[int]) -> int:\n        en = 0 # Energy\n        ex = 0 # Experience\n        \n        an = 0 # Added energy\n        ax = 0 # Added experience\n       \n        for ener, exp in zip(energy, experience):\n            if ener >= en:\n                an += (ener - en + 1)\n                en += (ener - en + 1)\n            if exp >= ex:\n                ax += (exp - ex + 1)\n                ex += (exp - ex + 1)\n            \n            en -= ener\n            ex += exp\n            \n        return max(0, (an - initialEnergy)) + max(0, (ax - initialExperience))\n```
['Greedy', 'Python']