Skip to content

Instantly share code, notes, and snippets.

@PreSoichiSumi
Created April 26, 2016 08:21
Show Gist options
  • Save PreSoichiSumi/dcf7adfbbe262323aecff2c171b54d8f to your computer and use it in GitHub Desktop.
Save PreSoichiSumi/dcf7adfbbe262323aecff2c171b54d8f to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int Q=sc.nextInt();
List<String> S=new ArrayList<String>();
List<String> T=new ArrayList<String>();
for(int i=0;i<Q;i++){
S.add(sc.next());
T.add(sc.next());
}
for(int i=0;i<Q;i++){
String sTemp=S.get(i);
String tTemp=T.get(i);
for(int j=0;j<26;j++){
if(tTemp.indexOf('a'+j)==-1)
sTemp= sTemp.replaceAll(String.valueOf((char)('a'+j)), "");
}
if(sTemp.indexOf(tTemp)!=-1){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment