Python, Java Elegant & Short | One pass
\nclass Solution:\n    """\n    Time:   O(n)\n    Memory: O(1)\n    """\n\n    def minNumberOfHours(self, energy: int, experience: int, energies: List[int], exp
```\nclass Solution:\n    """\n    Time:   O(n)\n    Memory: O(1)\n    """\n\n    def minNumberOfHours(self, energy: int, experience: int, energies: List[int], experiences: List[int]) -> int:\n        hours = 0\n\n        for eng, exp in zip(energies, experiences):\n            # Adding the missing amount of energy\n            extra_en = max(0, eng - energy + 1)\n            energy += extra_en\n\n            # Adding the missing amount of experience\n            extra_ex = max(0, exp - experience + 1)\n            experience += extra_ex\n\n            energy -= eng\n            experience += exp\n            hours += extra_en + extra_ex\n\n        return hours\n```\n\n```\npublic class Solution {\n\n    /**\n     * Time:   O(n)\n     * Memory: O(1)\n     */\n    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {\n        int hours = 0;\n\n        for (int i = 0; i < energy.length; ++i) {\n            // Adding the missing amount of energy\n            int extraEnergy = Math.max(0, energy[i] - initialEnergy + 1);\n            initialEnergy += extraEnergy;\n\n            // Adding the missing amount of experience\n            int extraExperience = Math.max(0, experience[i] - initialExperience + 1);\n            initialExperience += extraExperience;\n\n            initialEnergy -= energy[i];\n            initialExperience += experience[i];\n\n            hours += extraEnergy + extraExperience;\n        }\n\n        return hours;\n    }\n}\n```\n\nIf you like this solution remember to **upvote it** to let me know.\n
['Python', 'Java', 'Python3']