Getting RE(NZEC) (Java)
Here is my Code !!
import java.io.*;
public class MainRE
{
static String a;
static String b;
static private int ls[][];
static int arr[];
static int L;
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int testCount =Integer.parseInt(br.readLine());
for (int i = 1; i <= testCount; i++)
{
try
{
a=br.readLine();
b=br.readLine();
L=Integer.parseInt(br.readLine());
arr=new int [L];
initDp();
printLs();
}
catch(Exception e)
{
break;
}
}
}
public static void printLs()
{
for (int i = 0; i <= a.length(); i++)
{
for (int j = 0; j <= b.length(); j++)
{
if(ls[i][j]>0)updatearr(ls[i][j]);
}
}
for(int z=0;z<arr.length;z++)
{
System.out.print(arr[z]);
if(z<arr.length-1)System.out.print(" ");
}
System.out.println();
}
public static void updatearr(int n)
{
for(int z=0;z<arr.length;z++)
{
if(n>=(z+1))arr[z]++;
}
}
private static void initDp()
{
ls = new int[a.length() + 1][b.length() + 1];
for (int i = 0; i <= a.length(); i++)
ls[i][0] = 0;
for (int j = 0; j <= b.length(); j++)
ls[0][j] = 0;
for (int i = 1; i <= a.length(); i++)
{
for (int j = 1; j <= b.length(); j++)
{
ls[i][j] = (a.charAt(i - 1) != b.charAt(j - 1)) ? 0 : ls[i - 1][j - 1] + 1;
}
}
}
}