The Easiest and Concise O(N) Solution | Beats 100%
Code:-\n\n\n    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience)\n    {\n        int count=0;\n        for 
**Code:-**\n\n```\n    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience)\n    {\n        int count=0;\n        for (int i = 0; i < energy.length; i++)\n        {\n            if (initialExperience <= experience[i])\n            {\n                count+= experience[i]-initialExperience+1;\n                initialExperience+= experience[i]-initialExperience+1;     // if current experience < required experience, then we first bridge the gap and make the current experience more than the required experience      \n            }\n            initialEnergy-= energy[i];     // decrementing energy           \n            initialExperience+= experience[i];     // incrementing experience\n        }\n        if (initialEnergy < 1)\n            count+= 1-initialEnergy;     // if energy is still greater than 0, then no need of training \n        return count;\n    }\n```\t
['Greedy', 'Java', 'JavaScript']