✅Easy & Efficient Solution with Explanation || 100% Faster
Approach :\n\t There are three cases for this problem -\n\t\ti) Training for Energy gain.\n\t\tii) Traing for Experience gain.\n\t\tiii) Defeating the opponents
* **Approach :**\n\t* There are three cases for this problem -\n\t\ti) Training for Energy gain.\n\t\tii) Traing for Experience gain.\n\t\tiii) Defeating the opponents\n\t* For case - i :\n\t\t* Training hours required, hours += energy[i] - initialEnergy + 1\n\t\t* Energy gained, initialEnergy +=  .energy[i] - initialEnergy + 1\n\t* For case - ii :\n\t\t* Training hours required, hours += experience[i] - initialExperience + 1\n\t\t* Experience gained, initialExperience += experience[i] - initialExperience + 1\n\t* For case - iii :\n\t\t* Experience will increase, initialExperience += experience[i]\n\t\t* Energy will decrease, initialEnergy -= energy[i]\n\t* Finally return the ans (hours).\n\n* **Code :**\n```\nint minNumberOfHours(int initialEnergy, int initialExperience, vector<int>& energy, vector<int>& experience) {\n        \n        int n = energy.size();\n        int hours = 0;\n        \n        for(int i = 0; i < n; ++i)\n        {\n            // Case : 1\n            if(initialEnergy <= energy[i])\n            {\n                hours += energy[i] - initialEnergy + 1;\n                initialEnergy += energy[i] - initialEnergy + 1;\n            }    \n            \n            // Case : 2\n            if(initialExperience <= experience[i])\n            {\n                hours += experience[i] - initialExperience + 1;\n                initialExperience += experience[i] - initialExperience + 1;\n            }\n            \n            // Case : 3\n            initialExperience += experience[i] ;\n            initialEnergy -= energy[i];\n        }\n        return hours;\n    }\n```\n\n* **Complexity Analysis :**\n\t* Time Complexity : O(n)\n\t* Space Complexity : O(1)
['C', 'C++']