AgodaOA #4
Unique Digits in Range
Estimated EasyJudge-ready
Topics (AI-labelled)Bits & MathHashing
Given the closed interval [a,b], count the integers whose decimal representation has no repeated digit. The number 0 also counts as a valid integer.
The original rules are clear; this site adds the handling of zero, the upper bound and the standard input/output.
Input
One line with two integers a b (0≤a≤b≤10^18).
Output
Output the number of integers in the interval whose decimal digits are all distinct.
Example 1
Input:
5 11
Output:
6
Example 2
Input:
0 0
Output:
1
Example 3
Input:
98 102
Output:
2
Editorial
Loading solution…