C++ Greedy approach: O(N)
Connect with me on LinkedIn: https://www.linkedin.com/in/abhay5349singh/\n\nApproach:\n1. at each step gaining just enough energy & experience to win over curre
**Connect with me on LinkedIn**: https://www.linkedin.com/in/abhay5349singh/\n\n**Approach**:\n1. at each step gaining just enough energy & experience to win over current opponent\n2. in end, if initialEnergy > 1, we can reduce \' initialEnergy -1 \' amount of training time \n```\nclass Solution {\npublic:\n\n    int minNumberOfHours(int initialEnergy, int initialExperience, vector<int>& energy, vector<int>& experience) {\n        int n=energy.size();\n        \n        int time=0;\n        for(int i=0;i<n;i++){\n            int d1 = initialEnergy-energy[i], d2 = initialExperience-experience[i];\n            \n            time += (d1<=0 ? abs(d1)+1:0) + (d2<=0 ? abs(d2)+1:0); // adding \' +1\' as we need strictly greater energy & experience\n            \n            initialEnergy = max(initialEnergy-energy[i],1);\n            initialExperience += experience[i] + (d2<=0 ? abs(d2)+1:0);\n        }\n        \n        time -= (initialEnergy-1);\n        \n        return max(time,0);\n    }\n};\n```\n\n**Do UPVOTE if it helps :)**
['Greedy', 'C']