Company: Cisco_18july
Difficulty: medium
Count Arrays Problem Description Given an array of n integers called required_sums , there is another array of n integers called result that can be constructed to meet the following conditions: The values are non-decreasing, i.e., result[i] >= result[i-1] - 1 (1 < i <= n). The sum of digits of result[i] == required_sums[i] for every 1 <= i <= n. result[i] <= 5000 , for every 1 <= i <= n. Find the number of distinct ways that result can be constructed to satisfy the constraints. Since the answer can be large, compute it modulo (10 9 + 7). Note: Two arrays a and b of length n are distinct if a[i] is not equal to b[i] for at least one i in 1 <= i <= n. Complete the function countArrays in the editor with the following parameter: int required_sums[n]: the required sums of the digits. The function is expected to return an INTEGER. The function accepts INTEGER_ARRAY required_sums as parameter. The expected function signature is: int countArrays(vector<int>