Ashley loves Numbers and specially the numbers which have no repetition of digits, i.e., numbers which have unique digits only. You have to find the total number of integers with no repeated digits between

input format.

The first line of the input is an integer , total number of test cases. Each of the next lines contains two space separated integers N and M.

constraints:

1<=T<=10^5;

1<=N<=M<=10^6;

my solution..

#include <map>

#include <set>

#include <list>

#include <cmath>

#include <ctime>

#include <deque>

#include <queue>

#include <stack>

#include <string>

#include <bitset>

#include <cstdio>

#include <limits>

#include <vector>

#include <climits>

#include <cstring>

#include <cstdlib>

#include <fstream>

#include <numeric>

#include <sstream>

#include <iostream>

#include <algorithm>

#include <unordered_map>

int bits(long long int n)

{

int a[]={0,0,0,0,0,0,0,0,0,0,0};

while(n>0)

{

int temp=n%10;

n=n/10;

if(a[temp])

return 0;

else

a[temp]++;

}

return 1;

}

using namespace std;

int main() {

long long int t;

cin>>t;

long long int a[1000000];

for (long long int i=1;i<=100000;i++)

{

a[i]=a[i-1]+bits(i);

}

while(t–)

{

long long int n,m,count=0;

cin>>n>>m;

/*for(long long int i=n;i<m+1;i++)

{

if(bits(i))

count++;

}*/

count=a[m]-a[n-1];

cout<<count<<endl;

}

return 0;

}

## Recent Comments