dsa · easy
Self Dividing Numbers
A number is **self-dividing** if every digit of the number divides the number itself. A digit of 0 disqualifies the number (0 divides nothing). Given a range [left, right], return every self-dividing number in the range, in increasing order.
Arguments
left— lower bound of the range, inclusiveright— upper bound of the range, inclusive
Example
left = 1, right = 22
1 through 9 all qualify (single digits divide themselves). 10 fails (digit 0). 11 passes. 12 passes (1 and 2 both divide 12). 13 fails (3 does not divide 13). Continuing, the full list is [1,2,3,4,5,6,7,8,9,11,12,15,22].
left = 47, right = 85 → [48,55,66,77].
Constraints
1 <= left <= right <= 10^4
Examples
Example 1
Input: 1 22 Expected: [1,2,3,4,5,6,7,8,9,11,12,15,22]
Example 2
Input: 47 85 Expected: [48,55,66,77]
Example 3
Input: 1 1 Expected: [1]