Tap here to switch tabs
Problem
Submissions

Problem: Find the Count of Monotonic Pairs I

med
30 min
Try to solve the Find the Count of Monotonic Pairs I problem.

Statement

You are given an array of positive integers nums of length n.

A pair of non negative integer arrays (arr1, arr2) of length n is defined as monotonic if:

  • arr1 is non decreasing, which means arr1[0] ≤\leq arr1[1] ≤⋯≤\leq \dots \leq arr1[n - 1].

  • arr2 is non increasing, which means arr2[0] ≥\geq arr2[1] ≥⋯≥\geq \dots \geq arr2[n - 1].

  • arr1[i] + arr2[i] == nums[i] for every index i such that 0≤i≤n−10 \leq i \leq n - 1.

Return the count of monotonic pairs of arrays (arr1, arr2). Because the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤n==1 \leq n == nums.length ≤2000\leq 2000

  • 1≤1 \leq nums[i] ≤50\leq 50

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Count of Monotonic Pairs I

med
30 min
Try to solve the Find the Count of Monotonic Pairs I problem.

Statement

You are given an array of positive integers nums of length n.

A pair of non negative integer arrays (arr1, arr2) of length n is defined as monotonic if:

  • arr1 is non decreasing, which means arr1[0] ≤\leq arr1[1] ≤⋯≤\leq \dots \leq arr1[n - 1].

  • arr2 is non increasing, which means arr2[0] ≥\geq arr2[1] ≥⋯≥\geq \dots \geq arr2[n - 1].

  • arr1[i] + arr2[i] == nums[i] for every index i such that 0≤i≤n−10 \leq i \leq n - 1.

Return the count of monotonic pairs of arrays (arr1, arr2). Because the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤n==1 \leq n == nums.length ≤2000\leq 2000

  • 1≤1 \leq nums[i] ≤50\leq 50