Skip to content

Commit 8ceb455

Browse files
authored
Update find-the-count-of-monotonic-pairs-i.py
1 parent 45c4668 commit 8ceb455

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
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)
@@ -66,7 +66,7 @@ def countOfPairs(self, nums):
6666
:rtype: int
6767
"""
6868
MOD = 10**9+7
69-
dp = [1]*(max(nums)+1) # dp[j]: numbers of arr1, which is of length i+1 and arr1[i] is j
69+
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
7070
for i in xrange(1, len(nums)):
7171
# arr1[i-1] <= arr1[i]
7272
# => arr1[i]-arr1[i-1] >= 0 (1)

0 commit comments

Comments
 (0)