✅✅ Fastest C++ solution 2-4 ms || 🚀With full explaination every details of what and why with how.
Problem: In this problem it have been asking for number of minimum training hours required to win the competition. Winning competition meaning you have your Ene
**Problem**: In this problem it have been asking for number of minimum training hours required to win the competition. Winning competition meaning you have your Energy and Experience should be strictly greater than whatever given in Energy and Experience array.\n\n![image](https://assets.leetcode.com/users/images/fb2d4ab2-030c-4fc6-8d00-f3f50635b208_1661079758.4140139.png)\n\n**The following variety you may observe while solving it:**\n\n1.> Your initial energy and initial experience is greater than other opponents and in this you really don\'t have to do anything you can simply return zero.\n\n2.> Your initial energy and experience is not greater than other opponents than you require to train and increase your experience and energy. Yes its a bit confusing that am saying to training and also increasing the energy here i mean your required energy that you need to be more than other competents obviously while doing competition your energy will decrease.\n\nNow come to the approach here what we can observe your energy should remain 1 more than the complete energy array sum. So you can just add the energy array sum and your training hours will become (for energy not for experience) sum_energy - initial energy + 1.\n\nThis can\'t be valid for experience and for experience you need to do differently.\n\nFor experience you have to check your experience from next opponent there will be two following case:\n1. InitialExperience is more than opponents directly add the initialExperience and opponents experience as you WON.\n2. InitialExperience is less now you need training so you do opponentExp - initialExperience +1 this should be added in your trianing hours after this training procedure you can move on and add opponent Exp with your Exp + training hours.\n\nOnly this thing you need to do and return the trainig hours at the end.\n\n```\nclass Solution {\npublic:\n    int minNumberOfHours(int initialEnergy, int initialExperience, vector<int>& energy, vector<int>& experience) {\n\t    \n            int tr_energy = 0, tr_exp = initialExperience ,tr_hrs=0;\n            \n            for(int i=0;i<energy.size();i++) { tr_energy += energy[i] ; }\n            if(initialEnergy > tr_energy) return 0; //Base case when you have more initial Energy then all the opponents.\n            \n            for( int i=0; i<energy.size(); i++) \n            { \n               if(tr_exp<=experience[i])\n                 {\n                   tr_hrs += (experience[i] - tr_exp) + 1;\n                   tr_exp += experience[i] + tr_hrs;\n                 }            \n               else\n                 {\n                   tr_exp += experience[i];\n                 }\n            }\n\t\t\t//till this step we have tr_hrs for experience now add tr_hrs required for energy\n            tr_hrs += (tr_energy + 1) - initialEnergy;\n         \n            return tr_hrs;\n    }\n};\n```
['C']