题解 | #字符串字符匹配#
字符串字符匹配
http://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String str1 = sc.next();
String str2 = sc.next();
boolean res = getRes(str1,str2);
System.out.println(res);
}
}
private static boolean getRes(String str1, String str2) {
Set<Character> set = new HashSet<>();
for (int i = 0; i < str2.length(); i++) {
set.add(str2.charAt(i));
}
int n1 = set.size();
for (int i = 0; i < str1.length(); i++) {
set.add(str1.charAt(i));
}
int n2 = set.size();
if(n1 == n2){
return true;
}else{
return false;
}
}
}