dp(pos, sum, tight) that takes the current position in the number string, the current sum of digits, and a boolean tight that indicates if we are bound by the upper limit.pos is equal to the length of the number string and sum is within the range [min_sum, max_sum], return 1.pos is equal to the length of the number string but sum is not within the range, return 0.num2 if tight is true), and for each digit, recursively call dp with updated parameters.dp function for num2 and subtract the result of calling dp for num1 decremented by 1 to get the count of good integers between num1 and num2.num1 itself is a good integer, increment the result by 1.10^9 + 7.