A greedy solution for a greedy problem (C++)
The resultant array after performing all of the increment operations has to be strictly increasing (e.g., [1,2,3,4,5]).For a strictly increasing array each elem
The resultant array after performing all of the increment operations has to be strictly increasing (e.g., [1,2,3,4,5]).For a strictly increasing array each element has to be greater than its previous element by atleast 1.So, we can take a greedy approach such that whenever we find an element that is not greater than the previous ones we increment it by the dfference+1 and move on with our approach.(In short,the current element has to be the greatest one **yet**)\n```\nint cnt=0;\n        if(arr.size()==1)\n            return cnt;\n        int mx=-1;\n        for(int i=0;i<arr.size();i++){\n\t\t//if the present element is already greater than the maximum element then we don\'t have to increment anything. \n            if(arr[i]>mx){\n                mx=arr[i];            //updating the maximum element yet.\n                continue;\n            }\n            int temp=mx-arr[i]+1;  //minimum increment that we can do will be equal to : (maximum element - present element+1)\n            cnt+=mx-arr[i]+1;     //updating the count factor.\n            mx=temp+arr[i];      //Since we updated the present element we have to update the max. element as well (strictly increasing.)\n        }\n        return cnt;\n```
['Greedy', 'C']