C++ Simple Greedy Solution | O(n) | One-Pass
Every element should be atmost 1 greater than the previous element.\nSo, iterate the array & make every element nums[i] = max(nums[i], nums[i-1] + 1) and count 
Every element should be atmost 1 greater than the previous element.\nSo, iterate the array & make every element ```nums[i] = max(nums[i], nums[i-1] + 1)``` and count the no. of ```1```s to be added to make this change.\n**Code :**\n```\nclass Solution {\npublic:\n    int minOperations(vector<int>& nums) {\n        int count = 0, n = nums.size();\n        for(int i=1; i<n; i++){\n            int temp = nums[i];\n            nums[i] = max(nums[i], nums[i-1]+1);\n            count += nums[i]-temp;\n        }\n        return count;\n    }\n};\n```
['Greedy', 'C', 'C++']