Skip to content

Commit 9708cfd

Browse files
authored
Update find-the-count-of-monotonic-pairs-ii.py
1 parent 8ceb455 commit 9708cfd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Python/find-the-count-of-monotonic-pairs-ii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def countOfPairs(self, nums):
3838
:rtype: int
3939
"""
4040
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
41+
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
4242
for i in xrange(1, len(nums)):
4343
# arr1[i-1] <= arr1[i]
4444
# => arr1[i]-arr1[i-1] >= 0 (1)

0 commit comments

Comments
 (0)