Algorithm · Cisco · Easy
Problem You are given two integers X and Y. Determine how many integers in the range [0, X] have a digit sum exactly equal to Y. Function Signature Input X: a non‑negative integer representing the upper bound of the range. Y: a non‑negative integer representing the target digit sum. Output Return the count of integers n such that $$0 \le n \le X$$ and the sum of the decimal digits of n equals Y. If no such integer exists, return -1. Examples Example 1 Explanation: The…
Checking your access…