-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ037.java
More file actions
42 lines (34 loc) · 1.01 KB
/
J037.java
File metadata and controls
42 lines (34 loc) · 1.01 KB
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.Scanner;
public class J037{
public static void main(String[] args){
J037 pStudio = new J037();
pStudio.J037();
}
public void J037(){
Scanner s = new Scanner(System.in);
String s1;
String s2;
//97 - 122 소문자
s1 = s.nextLine();
s2 = s.nextLine();
int[] c1 = new int[122];
int[] c2 = new int[122];
int count = 0;
for(int i=0; i<s1.length(); i++)
c1[s1.charAt(i)]++;
for(int i=0; i<s2.length(); i++)
c2[s2.charAt(i)]++;
for(int i=97; i<122; i++)
if(c2[i] != 0 && c1[i] != 0)
if(c1[i] != c2[i]){
count = 1;
break;
}
if(count == 1)
System.out.println("NO");
else if(count == 0)
System.out.println("Yes");
}
}