Simple java code 0 ms beats 100 %
\n# Complexity\n- \n\n# Code\n\nclass Solution {\n    public int minNumberOfHours(int iE, int iEx, int[] en, int[] ex) {\n        int n=en.length;\n        int 
\n# Complexity\n- \n![image.png](https://assets.leetcode.com/users/images/0e3580d4-e416-4e4d-a5b9-c3db59f5a78e_1704550852.8141718.png)\n# Code\n```\nclass Solution {\n    public int minNumberOfHours(int iE, int iEx, int[] en, int[] ex) {\n        int n=en.length;\n        int sum=iEx;\n        int res=0;\n        for(int i=0;i<n;i++){\n            if(sum>ex[i]){\n                sum=sum+ex[i];\n            }\n            else{\n                res+=ex[i]-sum+1;\n                sum+=ex[i]+(ex[i]-sum+1);\n            }\n        }\n        sum=iE;\n        for(int i=0;i<n;i++){\n            if(sum>en[i]){\n                sum=sum-en[i];\n            }\n            else{\n                res+=en[i]-sum+1;\n                sum=1;\n            }\n        }\n        return res;\n    }\n}\n```
['Java']