Binary search sol
cpp\nclass Solution {\npublic:\n    \n    inline bool check(int exp, vector<int> &ene) {\n        for (auto i: ene) {\n            if (i >= exp) {\n            
```cpp\nclass Solution {\npublic:\n    \n    inline bool check(int exp, vector<int> &ene) {\n        for (auto i: ene) {\n            if (i >= exp) {\n                return false;\n            } else {\n                exp += i;\n            }\n        }\n        return true;\n    }\n    \n    int minNumberOfHours(int initialEnergy, int exp, vector<int>& energy, vector<int>& experience) {\n        int ans = 0;\n        for (auto &x: energy) {\n            ans += x;\n        }\n        ans = max(0, ans + 1 - initialEnergy);\n        \n        int lo = 0, hi = 100000, mid;\n        \n        while (lo < hi) {\n            mid = (lo + hi) >> 1;\n            if (check(mid + exp, experience)) {\n                hi = mid;\n            } else {\n                lo = mid + 1;\n            }\n        }\n        \n        return ans + lo;\n    }\n};\n```\n\nspent too much time on question 1 so directly doing binary search sol.
['Binary Search']