← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Meta/Leetcode 3250. Find the Count of Monotonic Pairs I
CodingOptional
Given an array nums of non-negative integers, determine how many ways you can decompose it into two sequences arr1 and arr2 such that:
numsi: arr1[i] + arr2[i] = nums[i]arr1 is non-decreasing (each element is greater than or equal to the previous)arr2 is non-increasing (each element is less than or equal to the previous)Return the count of valid decomposition pairs modulo 10^9 + 7.
nums must be split into two non-negative parts that sum to the original valuenums.length ≤ 2000nums[i] ≤ 50Example 1:
` Input: nums = [2, 3, 2] Output: 4 Explanation: Valid decompositions:
Example 2:
Input: nums = [5] Output: 6 Explanation: With one element, splits can be: (0,5), (1,4), (2,3), (3,2), (4,1), (5,0) All satisfy the monotonicity constraints trivially.
Example 3:
Input: nums = [1, 2, 3] Output: 4 Explanation: The increasing sum values allow several valid decompositions where arr1 grows and arr2 shrinks appropriately.