C++ | Greedy | Constant Space
```\nclass Solution {\npublic:\n    int minNumberOfHours(int Energyy, int Exp, vector& Energy, vector& experience) {\n        int exp=0;\n        int energy=0;\
```\nclass Solution {\npublic:\n    int minNumberOfHours(int Energyy, int Exp, vector<int>& Energy, vector<int>& experience) {\n        int exp=0;\n        int energy=0;\n        for(int i=0;i<experience.size();i++){\n            if(Exp>experience[i]){\n                Exp+=experience[i];\n            } \n            else{\n                int temp=experience[i]+1;\n                exp+=temp-Exp;\n                Exp=temp+experience[i];\n            }\n        }\n        int sum=1;\n        for(auto i:Energy) sum+=i;\n        if(sum>Energyy){\n            energy=sum-Energyy;\n        }\n        return exp+energy;\n    }\n};
['Greedy', 'C']