P31 · 1 second · 256 MB
Count Without a Digit
Return how many integers `x` with `0 ≤ x ≤ n` do **not** contain the decimal digit `d` (`0 ≤ d ≤ 9`). `n` is a non-negative integer. `0` contains the digit 0 and no others — so if `d !== 0`, `0` counts; if `d === 0`, `0` does not count.
function countWithoutDigit(n, d) → number
CONSTRAINTS
- 0 ≤ n ≤ 10¹²
- 0 ≤ d ≤ 9
Input: n = 25, d = 4
Output: 23
0..25 is 26 numbers; drop 4, 14, 24.
Input: n = 10, d = 4
Output: 10
0..10 minus 4.
Input: n = 0, d = 1
Output: 1
Input: n = 0, d = 0
Output: 0
1
2
3
4
5
6
7
8
Arena judges JavaScript in a Web Worker (1s wall-clock, then TLE). Samples are public; submit runs hidden tests too. C++/Python is a later swarm package.