[Java] Easy to Understand Solution with Explanation | O(N)
```\nclass Solution {\n    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {\n        int n = energy.lengt
```\nclass Solution {\n    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {\n        int n = energy.length;\n        int sum = 0;\n        int res = 0;\n\t\t//the energy needed is the total sum \n        for (int i : energy) {\n            sum += i;\n        }\n        res += sum - initialEnergy >= 0 ? sum - initialEnergy + 1: 0;\n        // if curExp < opponents\u2018 exp, we need to study to earn more\n        for (int i : experience) {\n            if (initialExperience <= i) {\n                res += i - initialExperience + 1;\n                initialExperience = i + 1;\n            }\n            initialExperience += i;\n        }\n        return res;\n    }\n}
[]