My issue
for(int i=0;i<x.length()-1;i++)
{
if(x.chartAt(i)== ‘?’||y.charAt(i)==‘?’)
flag= true;
if(x.charAt(i)==y.charAt(i))
flag =true;
}
if(flag==true)
System.out.println(“Yes”);
else
System.out.println(“No”);
}
why this code is genrate compile time error
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc= new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
String x=sc.next();
String y=sc.next();
boolean flag=false;
for(int i=0;i<x.length()-1;i++)
{
if(x.chartAt(i)== '?'||y.charAt(i)=='?')
flag= true;
if(x.charAt(i)==y.charAt(i))
flag =true;
}
if(flag==true)
System.out.println("Yes");
else
System.out.println("No");
}
}
}
Learning course: Strings using Java
Problem Link: Chef and the Wildcard Matching Practice Problem in - CodeChef