Python 3 || 9 lines, no arrays  || T/S: 99% / 81%
\n\nclass Solution:\n    def countOfPairs(self, nums: List[int]) -> int:\n\n        n, mn = len(nums), nums.pop(0)\n        num1, num2 = 0, mn\n    \n        fo
\n```\nclass Solution:\n    def countOfPairs(self, nums: List[int]) -> int:\n\n        n, mn = len(nums), nums.pop(0)\n        num1, num2 = 0, mn\n    \n        for num in nums:\n            if num < num1: return 0\n\n            if num > num1 + num2: \n                num1 = num - num2  \n\n            num2 = num - num1\n\n            if num2 < mn: mn = num2\n        \n        return comb(n + mn, mn) % 1_000_000_007\n```\n[https://leetcode.com/problems/find-the-count-of-monotonic-pairs-ii/submissions/1352454766/](https://leetcode.com/problems/find-the-count-of-monotonic-pairs-ii/submissions/1352454766/)\n\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(1), in which *N* ~ `len(nums)`.
['Python3']