Count Arrays

Company: Cisco_18july

Difficulty: medium

Problem Statement

Count Arrays Problem Description You are given an array required_sums of n integers. Count the arrays result of n integers that satisfy all three of the following conditions: result is non-decreasing: result[i] >= result[i - 1] for every i with 1 < i <= n . The sum of the decimal digits of result[i] equals required_sums[i] , for every i with 1 <= i <= n . 0 <= result[i] <= 5000 , for every i with 1 <= i <= n . Two arrays a and b of length n are different if a[i] is not equal to b[i] for at least one i . Since the count can be large, report it modulo 10^9 + 7 . (inferred - condition 1 is exactly result[i] >= result[i - 1] . One legacy copy of this statement rendered it as result[i] >= result[i - 1] - 1 ; the source screenshot illustrates the first condition as the plain chain 4998 <= 4999 <= 4999 and both copies call the array "non-decreasing", so the - 1 is treated as a transcription artifact of the subscript [i - 1] . Example 4 below is included