✔️Python, C++,Java|| Beginner level||Simple-Short-Solution||Greedy Approach✔️
Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome.\n___\n__\nQ
***Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome*.**\n___________________\n_________________\n***Q2383. Minimum Hours of Training to Win a Competition***\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\n\u2705 **Python  Code** :\n```\nclass Solution:\n    def minNumberOfHours(self, initialEnergy: int, initialExperience: int, energy: List[int], experience: List[int]) -> int:\n        traning = 0\n        totalEnergy = sum(energy)\n        if initialEnergy <= totalEnergy:\n            traning += (totalEnergy - initialEnergy + 1)\n        for opponentExperience in experience:\n            if initialExperience <= opponentExperience:\n                traning += (opponentExperience - initialExperience + 1)\n                initialExperience = opponentExperience + 1\n            initialExperience += opponentExperience\n            \n        return traning\n```\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\n\n\u2705 **Java Code** :\n```\nclass Solution {\n    public int minNumberOfHours(int initialEnergy, int initialExperience, int[] energy, int[] experience) {\n        int traning=0,n=energy.length;\n        for(int i=0;i<n;i++)\n        {\n            if(energy[i]>=initialEnergy)\n            {\n                int diff=energy[i]-initialEnergy;\n                traning+=diff+1;\n                initialEnergy+=diff+1;\n            }\n            if(experience[i]>=initialExperience)\n            {\n                int diff=experience[i]-initialExperience;\n                traning+=diff+1;\n                initialExperience+=diff+1;\n            }\n            initialEnergy-=energy[i];\n            initialExperience+=experience[i];\n        }\n        return traning;\n    }\n    \n}\n```\n\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\n\u2705 **C++  Code** :\n```\nclass Solution {\npublic:\n    int minNumberOfHours(int initialEnergy, int initialExperience, vector<int>& energy, vector<int>& experience) {\n        int traning=0,n=energy.size();\n        for(int i=0;i<n;i++)\n        {\n            if(energy[i]>=initialEnergy)\n            {\n                int diff=energy[i]-initialEnergy;\n                traning+=diff+1;\n                initialEnergy+=diff+1;\n            }\n            if(experience[i]>=initialExperience)\n            {\n                int diff=experience[i]-initialExperience;\n                traning+=diff+1;\n                initialExperience+=diff+1;\n            }\n            initialEnergy-=energy[i];\n            initialExperience+=experience[i];\n        }\n        return traning;\n    }\n};\n```\n____________________________________________________________________________________________________________________\n____________________________________________________________________________________________________________________\nIf you like the solution, please upvote \uD83D\uDD3C\nFor any questions, or discussions, comment below. \uD83D\uDC47\uFE0F\n
['Greedy', 'C', 'Python', 'Java']