Simple C++ and Java Solution  Time O(N)  and Space O(1)
C++ solution: \n\n\n\nclass Solution {\npublic:\n    int minOperations(vector<int>& nums) {\n        if(nums.size()<1)return 0;\n        int cost=0;\n        fo
**C++ solution:** \n```\n\n\nclass Solution {\npublic:\n    int minOperations(vector<int>& nums) {\n        if(nums.size()<1)return 0;\n        int cost=0;\n        for(int i=1;i<nums.size();i++)\n        {\n            if(nums[i]<=nums[i-1])\n            {\n                cost+=nums[i-1]-nums[i]+1;\n                nums[i]+=nums[i-1]-nums[i]+1;\n            }\n            \n        }\n        return cost;\n    }\n};\n```\n\n**Java Solution:**\n\n```\nclass Solution {\n    public int minOperations(int[] nums) {\n        int cost=0;\n        for(int i=1;i<nums.length;i++)\n        {\n           if(nums[i-1]>=nums[i])\n           {\n               int diff=nums[i-1]-nums[i];\n               cost=cost+diff+1;\n               nums[i]=nums[i]+diff+1;\n           }\n        }\n        return cost;\n        \n    }\n};\n\n```\n\n\n
['C', 'Java']