Company: PayPal SWE Intern_30oct
Difficulty: medium
Array Construction 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 in result are non-decreasing, i.e., result[i] <= result[i+1] for every 1 <= i < n . The sum of digits of result[i] must be equal to required_sums[i] for every 1 <= i <= n . result[i] <= 5000 for every 1 <= i <= n . Find the number of distinct arrays result that 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] != b[i] for at least one index i where 1 <= i <= n . For instance, consider n = 3 and required_sums = [30, 31, 31] . The following result arrays satisfy the conditions: result = [4998, 4999, 4999] result = [4989, 4999, 4999] result = [4899, 4999, 4999] result = [3999, 4999, 4999] Let's verify for result = [4998, 4999, 4999] (ass