public class Solution {
public int countDigitOne(int n) {
int result = 0;
for (long m = 1; m <= n; m *= 10) {
long left = n / m;
long right = n % m;
result += (left + 8) / 10 * m;
if (left % 10 == 1) {
result += right + 1;
}
}
return result;
}
}
Number of Digit One
最新推荐文章于 2022-12-07 22:01:39 发布