We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8ceb455 commit 9708cfdCopy full SHA for 9708cfd
Python/find-the-count-of-monotonic-pairs-ii.py
@@ -38,7 +38,7 @@ def countOfPairs(self, nums):
38
:rtype: int
39
"""
40
MOD = 10**9+7
41
- dp = [1]*(max(nums)+1) # dp[j]: numbers of arr1, which is of length i+1 and arr1[i] is j
+ dp = [int(i <= nums[0]) for i in xrange(max(nums)+1)] # dp[j]: numbers of arr1, which is of length i+1 and arr1[i] is j
42
for i in xrange(1, len(nums)):
43
# arr1[i-1] <= arr1[i]
44
# => arr1[i]-arr1[i-1] >= 0 (1)
0 commit comments