Ashley Loves Numbers (Financial Engineer)
Ashley loves Numbers—but only the ones without repeating digits. For example, she loves 12 but hates 11. Given two integers, n and m, Ashley wants to find the count, c, of numbers she will love that are in the inclusive range between n and m.
Complete the countNumbers function in your editor. It has 1 parameter: a 2D array of integers, arr, containing q rows of n and m values. For each row i in arr (where 0 ≤ i < q), the function must print the count (ci) of integers having no repeated digits in the inclusive range between ni and mi.
Input Format
The locked stub code in your editor reads the following input from stdin and passes it to your function:
The first line contains an integer, q, denoting the number of rows in arr.
The second line contains an integer, 2, denoting the number of columns in arr.
Each line i of the q subsequent lines (where 0 ≤ i < q) contains 2 space-separated integers describing the respective values of ni and mi, for row i in arr.
Output Format
For each row i in arr, your function must print the count, ci, of numbers Ashley loves in the inclusive range between ni and mi, on a new line. (I turned the output type into int[] for convience :)
1Example 1
Constraints
Limits and guarantees your solution can rely on.
1 ≤ q ≤ 1051 ≤ n ≤ m ≤ 106