🔥🔥🔥 Python Simple Solution 🔥🔥🔥 | Bottom-up DP | O(n * m) Time, O(m) Space
Intuition\nGiven an index i,\n1. If nums[i] >= nums[i - 1], then the first available number for i num = nums[i] - nums[i - 1].\nBecause the number in arr2 will 
# Intuition\nGiven an index i,\n1. If $$nums[i] >= nums[i - 1]$$, then the first available number for i $$num = nums[i] - nums[i - 1]$$.\nBecause the number in arr2 will be $$nums[i] - num = nums[i] - (nums[i] - nums[i - 1]) = nums[i - 1] \\le nums[i - 1]$$\n2. If $$num[i] < nums[i - 1]$$, then the first available number starts from 0.\n\nThen every available number will be the sum of the previous ones.\n\n\n# Solution\nn = length of nums\nm = maximum of nums\n\nTime complexity: $$O(n * m)$$\nSpace complexity: $$O(m)$$\n```\nclass Solution:\n    def countOfPairs(self, nums: List[int]) -> int:\n        mod = 10 ** 9 + 7\n\n        dp = [1] * (nums[0] + 1)\n        for i in range(1, len(nums)):\n            new_dp = [0] * (nums[i] + 1)\n            diff = max(nums[i] - nums[i - 1], 0)\n            count = 0\n            for j in range(diff, nums[i] + 1):\n                count = (count + dp[j - diff]) % mod\n                new_dp[j] = count\n            dp = new_dp\n\n        return sum(dp) % mod\n```
['Python3']