FastPrepFastPrep
Problem Brief

Ashley Loves Numbers (Financial Engineer)

INTERNOA

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

Input
arr = [[1, 20], [9, 19]]
Output
[19, 10]
Explanation
For the first query, Ashley loves all numbers from 1 to 20 except for 11, so the count is 19. For the second query, Ashley loves all numbers from 9 to 19 except for 11, so the count is 10.

Constraints

Limits and guarantees your solution can rely on.

1 ≤ q ≤ 105
1 ≤ n ≤ m ≤ 106
public int[] countNumbers(int[][] arr) {
  // write your code here
}
Input

arr

[[1, 20], [9, 19]]

Output

[19, 10]

Sign in to submit your solution.