-
Notifications
You must be signed in to change notification settings - Fork 15
/
p260.java
42 lines (27 loc) · 1018 Bytes
/
p260.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.Arrays;
import java.util.Scanner;
/**
* @author Rubén Saiz
*/
public class p260 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int casos = s.nextInt(); s.nextLine();
String str1, str2;
for (int c = 0; c < casos; c++) {
str1 = s.nextLine().replace(" ", "").toLowerCase();
str2 = s.nextLine().replace(" ", "").toLowerCase();
if (str1.length() != str2.length()) System.out.println("NO");
else {
boolean anagram = true;
int[] table = new int[58];
for (char letra : str1.toCharArray()) table[letra - 'A']++;
for (char letra : str2.toCharArray()) {
table[letra - 'A']--;
if (table[letra - 'A'] < 0) anagram = false;
}
System.out.println( anagram ? "SI" : "NO" );
}
}
}
}