Count Distinct Integers After Removing Zeros
You are given a positive integer n.
For every integer x from 1 to n, write down the integer obtained by removing all zeros from the decimal representation of x.
Return an integer denoting the number of distinct integers written down.
Example 1
Input
n = 10Output
9The integers written down are 1, 2, 3, 4, 5, 6, 7, 8, 9, and 1, so there are 9 distinct integers.
Example 2
Input
n = 3Output
3The integers written down are 1, 2, and 3, so there are 3 distinct integers.
Constraints
- 1 <= n <= 10^15