Java solution | O(n)
Please Upvote !!!\n#### Weekly Contest 307\n##### (21 August, 2022)\n\nclass Solution {\n    public int minNumberOfHours(int initialEnergy, int initialExperienc
### ***Please Upvote !!!***\n#### Weekly Contest 307\n##### (21 August, 2022)\n```\nclass Solution {\n    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {\n        \n        int n = energy.length;\n        int ans = 0;\n        \n        for (int i = 0; i < n; i++) {\n            \n            if (initialEnergy <= energy[i]) {\n                int tempEnergy = energy[i] + 1 - initialEnergy;\n                ans += tempEnergy;\n                initialEnergy += tempEnergy;\n            }\n            \n            if (initialExperience <= experience[i]) {\n                int tempExperience = experience[i] + 1 - initialExperience;\n                ans += tempExperience;\n                initialExperience += tempExperience;\n            }\n            \n            initialEnergy -= energy[i];\n            initialExperience += experience[i];\n        }\n        \n        return ans;\n    }\n}\n\n// TC: O(n), SC: O(1)\n```
['Java']