0ms C++ | Single loop succinct
Intuition & ApproachComplexity

Time complexity: O(n)


Space complexity:

Code
# Intuition & Approach

# Complexity

- Time complexity: $$O(n)$$

- Space complexity:

# Code

```cpp []
class Solution {
public:
    int minNumberOfHours(int ie, int ix, vector<int>& E, vector<int>& X) {
        int l = E.size(), h = 0;

        for (int i = 0; i < l; i++) {
            int de = ie - E[i], dx = ix - X[i];

            // Training if required
            if (de <= 0)
                ie += abs(de) + 1, h += abs(de) + 1;
            if (dx <= 0)
                ix += abs(dx) + 1, h += abs(dx) + 1;

            // Defeat i'th
            ie -= E[i], ix += X[i];
        }

        return h;
    }
};
```
['C++']