给两个字符串
统计每个字符出现的个数
排序
看是否相同
熟悉了一下JAVA的数组操作
会了
Arrays.sort Array.equals 用法
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while (cin.hasNextLine()) {
char[] a = cin.nextLine().toCharArray();
int[] ai = new int[26];
for (char x : a) {
ai[x - 'A']++;
}
char[] b = cin.nextLine().toCharArray();
int[] bi = new int[26];
for (char x : b) {
bi[x - 'A']++;
}
Arrays.sort(ai);
Arrays.sort(bi);
if (Arrays.equals(ai, bi)) System.out.println("YES");
else System.out.println("NO");
}
}
}