Getting a run time error for the problem : Password Cracking
this is my code…
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
class Password
{
public int x,l=0,m=0;
public String s[];
public int t[],pl,plA[];
public char t1[],t2[],t3[];
public int y,w,temp=0,temp2=0;
public Password() throws IOException
{
Scanner in=new Scanner(System.in);
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
x=in.nextInt();
s=new String[2*x];
t=new int[x];
for(int i=0;i<2*x;i++)
{
try{s[i]=(String)br.readLine();}
catch(Exception e){System.out.println();}
if(s[i].length()<1)
{
if(i%2==0)
l++;
else
m++;
}
}
if(l==0 && x<=50 && m==0)
{
for(int i=0;i<x;i++)
{
if(s[2*i].matches("(.*)"+s[2*i+1]+"(.*)"))
t[i]=0;
}
for(int i=0;i<x;i++)
{
pl=(s[2*i].length()-s[2*i+1].length()+1);
plA=new int[pl];
for(int j=0; j<pl;j++)
{
y=s[2*i].length(); w=s[2*i+1].length();
t3=new char[y]; t3=s[2*i].toCharArray();
t1=new char[w];
temp=0;
//System.out.println("---->"+j+"--->"+i);
for(int p=j;p<j+w;p++)
{
//System.out.println(temp);
t1[temp]=t3[p];
temp++;
}
t2=new char[w]; t2=s[2*i+1].toCharArray();
temp2=0;
//System.out.println(t1); System.out.println(t2);
for(int k=0;k<w;k++)
{
if(t1[k]==t2[k])
temp2++;
}
plA[j]=w-temp2;
//System.out.println("###"+plA[j]);
temp2=0;
}
//System.out.println("plA ");
//System.out.println(Arrays.toString(plA));
t[i]=minA(plA);
}
System.out.println(" ");
for(int i=0; i<x;i++)
{
System.out.println(t[i]);
}
}//end of if
else
{
System.out.println("Error exist in the input");
}
}
public int minA(int A[])
{
int min=A[0];
for(int i=1;i<A.length;i++)
{
if(A[i]<min)
min=A[i];
}
return min;
}
public static void main(String[] args)
{
try{
new Password();}
catch (Exception e)
{System.out.println("Exception Occured....");}
}
}