python 3 solution beats 99.8% TIME , O(1) SPACE used
stats\n Describe your first thoughts on how to solve this problem. \n\n\n\n# Approach\n Describe your approach to solving the problem. \nwe can have a temporary
# stats\n<!-- Describe your first thoughts on how to solve this problem. -->\n![Screenshot 2023-08-10 at 6.23.17 PM.png](https://assets.leetcode.com/users/images/945e08c8-13a1-40ca-b812-c74dd9a55eb4_1691672043.6610649.png)\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nwe can have a temporary variable s and a counting variable c\ns initialized with first element of array\nif s is greater than or equal to current elemnet then we take difference between s and current lement and add 1 to make it number 1 greater than s\n` 5 2` , `s=5`,`c added to 5-2+1`,`s=6` the next element\nelse s is updated to new element \nreturning cdoes the job\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n**________O(N)**\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n**________O(1)**\n# Code\n```\nclass Solution:\n    def minOperations(self, nums: List[int]) -> int:\n        c=0\n        s=nums[0]\n        for i in range(1,len(nums)):\n            if s>=nums[i]:\n                c+=s-nums[i]+1\n                s+=1\n            else:\n                s=nums[i]\n        return c\n```
['Array', 'Python3']