I need help in this problem. I have tried all the test cases on Udebug as well, they are passing. But Vjudge is not accepting my code.
package DigitDp;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
public class Investigation {
public static void main(String[] args)throws IOException {
Scanner s=new Scanner(System.in);
int test=s.nextInt();
StringBuilder print=new StringBuilder();
int c=1;
while(test--!=0){
print.append("Case "+c+": ");
c++;
char a[]=Integer.toString(s.nextInt()-1).toCharArray();
char b[]=s.next().toCharArray();
int m=s.nextInt();
if(m>=100){
print.append("0\n");
continue;
}
int r=solve(b,m);
int l=solve(a,m);
int ans=r-l;
print.append(ans+"\n");
}
System.out.println(print.toString());
}
public static int solve(char a[],int m){
int n=a.length;
HashMap<ArrayList<Integer>,Integer> map=new HashMap<>();
ArrayList<Integer> temp=new ArrayList<>();
temp.add(0);temp.add(0);temp.add(1);
map.put(temp,1);
for(int i=1;i<=n;i++){
int cd=a[i-1]-48;
HashMap<ArrayList<Integer>,Integer> curr=new HashMap<>();
for(int p=0;p<=9;p++){
for(ArrayList<Integer> t:map.keySet()){
int x=t.get(0);
int y=t.get(1);
int z=t.get(2);
int nx=(x*10+p)%m;
int ny=(y+p)%m;
int val=map.get(t);
if(p<cd){
ArrayList<Integer> te=new ArrayList<>();
te.add(nx);te.add(ny);te.add(0);
curr.put(te,curr.getOrDefault(te,0)+val);
}
else if(p==cd){
if(z==0){
ArrayList<Integer> te=new ArrayList<>();
te.add(nx);te.add(ny);te.add(0);
curr.put(te,curr.getOrDefault(te,0)+val);
}
if(z==1){
ArrayList<Integer> te2=new ArrayList<>();
te2.add(nx);te2.add(ny);te2.add(1);
curr.put(te2,curr.getOrDefault(te2,0)+val);
}
}
else{
if(z==0){
ArrayList<Integer> te=new ArrayList<>();
te.add(nx);te.add(ny);te.add(0);
curr.put(te,curr.getOrDefault(te,0)+val);
}
}
}
}
map=curr;
}
int ans=0;
for(ArrayList<Integer> t:map.keySet()){
if(t.get(0)==0&&t.get(1)==0){
ans+=map.get(t);
}
}
return ans;
}
}
Here's the problem Link