Greedy Incremental Adjustment to Enforce Strict Monotonicity
IntuitionThe goal is to transform the input array into a strictly increasing sequence using the minimum number of increment operations. To achieve this, we scan
# Intuition
The goal is to transform the input array into a strictly increasing sequence using the minimum number of increment operations. To achieve this, we scan the array from left to right. If the current element is not strictly less than the next, we increment the next element until it becomes greater. This greedy approach ensures we only perform the necessary minimum number of operations at each step.



# Approach
- Initialize a counter to keep track of operations.

- Iterate through the array from the first to the second-to-last element.

- If the next element is less than or equal to the current, increment it until it becomes strictly greater.

- Add the number of increments performed to the counter.

- Return the final count.

# Complexity
- Time complexity:
O(n) – Each element is visited once, and though inner increments happen, each increment operation corresponds to an increase in array value, bounded by the overall value range.
- Space complexity:
O(1) – No extra space is used besides a few variables; the input vector is modified in place (though Leetcode typically doesn't penalize for this).
# Code
```cpp []
class Solution {
public:
    int minOperations(vector<int>& nums) {
        int counter = 0; 
        for(int i = 0; i < nums.size() -1; i++)
        {
            while(nums[i] >= nums[i+1])
            {
                nums[i+1]++;
                counter++;
            }
        }
        return counter;
    }
};
```
['Array', 'Greedy', 'Simulation', 'C++']