Simple java code 2 ms beats 99 %
\n# Complexity\n- \n\n# Code\n\nclass Solution {\n    public int minOperations(int[] nums) {\n        int max = nums[0];\n        int sum = 0;\n        for(int 
\n# Complexity\n- \n![image.png](https://assets.leetcode.com/users/images/41cfae20-8e5d-488f-9d34-845158dadc82_1705203696.8841999.png)\n# Code\n```\nclass Solution {\n    public int minOperations(int[] nums) {\n        int max = nums[0];\n        int sum = 0;\n        for(int i=1; i<nums.length; i++) {\n            if(nums[i]>max) {\n                max = nums[i];\n            } else {\n                max++;\n                sum += max - nums[i];\n            }\n        }\n        return sum;\n    }\n}\n```
['Java']