题解 | #字符串字符匹配#
字符串字符匹配
http://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
//哈希存储
import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s=null;
while((s=br.readLine())!=null){
char[] chars=s.toCharArray();
String strlong=br.readLine();
char[] charslong=strlong.toCharArray();
int ashort[]=new int[26];
int along[]=new int[26];
for(int i=0;i<chars.length;i++){
ashort[chars[i]-'a']=1;
}
for(int i=0;i<charslong.length;i++){
along[charslong[i]-'a']=1;
}
int flag=0;
for(int i=0;i<26;i++){
if(ashort[i]==1 && along[i]!=1) flag=1;
}
if(flag==0) System.out.println("true");
else if(flag==1) System.out.println("false");
}
}
}