ALPHABETS
/* 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 AlphaBet4
{
public static void main (String[] args) throws java.lang.Exception
{
int T,count=0;
String S=null,L=null;
Scanner sc=new Scanner(System.in);
S=sc.next();
T=sc.nextInt();
for(int tc=1;tc<=T;tc++){
L=sc.next();
count=0;
for(int i=0;i<S.length();i++){
for(int j=0;j<L.length()-1;j++){
if(S.charAt(i)==L.charAt(j)){
//System.out.println("S[%d]"+i+""+S.charAt(i)+"j[%d]"+j+L.charAt(i));
//System.out.println("Yes");
count=1;
break;
}
}
}
if(count==1)
System.out.println("Yes");
else
System.out.println("No");
}
}
}
No comments:
Post a Comment