3250. Find the Count of Monotonic Pairs I Hard
1/**
2 * [3250] Find the Count of Monotonic Pairs I
3 *
4 * You are given an array of positive integers nums of length n.
5 * We call a pair of non-negative integer arrays (arr1, arr2) monotonic if:
6 *
7 * The lengths of both arrays are n.
8 * arr1 is monotonically non-decreasing, in other words, arr1[0] <= arr1[1] <= ... <= arr1[n - 1].
9 * arr2 is monotonically non-increasing, in other words, arr2[0] >= arr2[1] >= ... >= arr2[n - 1].
10 * arr1[i] + arr2[i] == nums[i] for all 0 <= i <= n - 1.
11 *
12 * Return the count of monotonic pairs.
13 * Since the answer may be very large, return it modulo 10^9 + 7.
14 *
15 * <strong class="example">Example 1:
16 * <div class="example-block">
17 * Input: <span class="example-io">nums = [2,3,2]</span>
18 * Output: <span class="example-io">4</span>
19 * Explanation:
20 * The good pairs are:
21 * <ol>
22 * ([0, 1, 1], [2, 2, 1])
23 * ([0, 1, 2], [2, 2, 0])
24 * ([0, 2, 2], [2, 1, 0])
25 * ([1, 2, 2], [1, 1, 0])
26 * </ol>
27 * </div>
28 * <strong class="example">Example 2:
29 * <div class="example-block">
30 * Input: <span class="example-io">nums = [5,5,5,5]</span>
31 * Output: <span class="example-io">126</span>
32 * </div>
33 *
34 * Constraints:
35 *
36 * 1 <= n == nums.length <= 2000
37 * 1 <= nums[i] <= 50
38 *
39 */
40pub struct Solution {}
41
42// problem: https://leetcode.com/problems/find-the-count-of-monotonic-pairs-i/
43// discuss: https://leetcode.com/problems/find-the-count-of-monotonic-pairs-i/discuss/?currentPage=1&orderBy=most_votes&query=
44
45// submission codes start here
46
47impl Solution {
48 pub fn count_of_pairs(nums: Vec<i32>) -> i32 {
49 0
50 }
51}
52
53// submission codes end
54
55#[cfg(test)]
56mod tests {
57 use super::*;
58
59 #[test]
60 fn test_3250() {
61 }
62}
63
Back
© 2025 bowen.ge All Rights Reserved.