I’m getting a runtime error. But when I compile it with custom input it works.
import java.io.*;
class play
{
int l1,l2;
String s1,s2;
char A[]=new char[100];
char B[]=new char[100];
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
void main()throws IOException
{
int t;
t=Integer.parseInt(br.readLine());
while(t–>0)
{
s1=br.readLine();
s2=br.readLine();
s1=s1.toLowerCase();
s2=s2.toLowerCase();
arr();
check();
}
}
void arr()
{
l1=s1.length();
l2=s2.length();
for(int i=0;i<l1;i++)
{
A[i]=s1.charAt(i);
}
for(int i=0;i<l2;i++)
{
B[i]=s2.charAt(i);
}
}
void check()
{
int j=0,count=0,c2=0;
for(int i=0;i<l1;i++)
{
if(A[i]==B[j])
{
count++;
j++;
}
}
j=0;
for(int i=(l1-1);i>=0;i–)
{
if(A[i]==B[j])
{
c2++;
j++;
}
}
if((count==l2)&&(c2!=l2))
{
System.out.println(1);
}
else
if((count!=l2)&&(c2==l2))
{
System.out.println(2);
}
else
if((count==l2)&&(c2==l2))
{
System.out.println("3");
}
else
System.out.println("0");
}
public static void main(String args[])throws IOException
{
play ob=new play();
ob.main();
}
}