Find the Count of Monotonic Pairs II - Practice Coding | SlaveCode
0
0123456789
0
0123456789
:
0
0123456789
0
0123456789
3251. Find the Count of Monotonic Pairs II
Hard
50 Points
Array
Math
Dynamic Programming
Combinatorics
Prefix Sum
You are given an array of positive integers nums of length n.
We call a pair of non-negative integer arrays (arr1, arr2) monotonic if:
Return the count of monotonic pairs.
Since the answer may be very large, return it modulo 109 + 7.
Examples
Example 1
Input: nums = [2,3,2]
Output: 4
Explanation:
The good pairs are:
Example 2
Input: nums = [5,5,5,5]
Output: 126
Constraints
1 <= n == nums.length <= 2000
1 <= nums[i] <= 1000
3251. Find the Count of Monotonic Pairs II
Hard
50 Points
Array
Math
Dynamic Programming
Combinatorics
Prefix Sum
You are given an array of positive integers nums of length n.
We call a pair of non-negative integer arrays (arr1, arr2) monotonic if:
Return the count of monotonic pairs.
Since the answer may be very large, return it modulo 109 + 7.
Examples
Example 1
Input: nums = [2,3,2]
Output: 4
Explanation:
The good pairs are: