Java O(n) easy
\nclass Solution {\n    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {\n        int res = 0, n = energy
```\nclass Solution {\n    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {\n        int res = 0, n = energy.length, sum=0;\n        for(int i=0; i<n-1; i++){\n            sum+=energy[i];\n        }\n        res+=Math.max(0, energy[n-1]+1+sum-initialEnergy);\n        for(int i=0; i<n; i++){\n            if(experience[i]>=initialExperience){\n                res += experience[i]+1-initialExperience;\n                initialExperience = experience[i]+1;\n            }\n            initialExperience+=experience[i];\n        }\n        return res;\n    }\n}\n```
[]