I have been trying to get this problem accepted but I have failed.
At first I tried it in C but it always showed wrong answer so then I tried it in JAVA then it showed time limit exceeded . If someone could point me in the right direction and tell me how could I improve my code I’d be very greatfull .
**Problem:**http://www.codechef.com/problems/DDISH
CODE:
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
double i,r,l;
int t,j,d,c,ctr;int a[]=new int[10];//an array for every digit
Scanner input = new Scanner(System.in);
t=input.nextInt();
ctr=0;
while(t!=0)
{ctr=0;
Arrays.fill(a, 0);//initialising the array for each test case
r=input.nextDouble();
l=input.nextDouble();
for(i=r;i<=l;i++)
{c=(int) i;
Arrays.fill(a, 0);//initialising the array for every number
while(c!=0)
{
d=c%10;
a[d]++;
if(a[d]>1)//if any digit repeats then exit the loop
break;
c=c/10;
}
if(c!=0)//if all the digits are not traversed then it is not delicious
continue;
ctr++;
}
System.out.println(ctr);
t--;}
}
}