cswork / OAOpen practice workspace

SalesforceOA #9

Count Numbers with Unique Digits

Estimated EasyJudge-ready

Topics (AI-labelled)HashingSimulation

Given a list of numbers, count the elements within the 0-based closed index interval [l,r] whose decimal representation has no repeated digits. The interval is not a value range, and repeated valid elements are counted separately. The original example explanation mistakenly wrote 51/60 as 5/6; this site corrects it using the index semantics that all three examples agree on.

Input

The first line contains n l r, and the second line contains n non-negative integers. On this site 1≤n≤200000, 0≤l≤r<n, 0≤numbers[i]≤10⁹, written in ordinary decimal without extra leading zeros.

Output

Output the number of elements.

Example 1

Input:

8 1 5
1 2 11 55 989 51 60 7007

Output:

2

Example 2

Input:

8 0 7
1 2 11 55 989 51 60 7007

Output:

4

Example 3

Input:

8 5 7
1 2 11 55 989 51 60 7007

Output:

2

Example notes

The three answers are 2, 4, and 2; in the first example, the valid numbers at indices 1..5 are 2 and 51.

Editorial

Loading solution…