-
Notifications
You must be signed in to change notification settings - Fork 138
/
Solution.java
35 lines (28 loc) · 853 Bytes
/
Solution.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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static int makingAnagrams(String s1, String s2){
int[] cache = new int[100];
int counter = 0;
for (int i = 0; i < s1.length(); i++) {
cache[Character.getNumericValue(s1.charAt(i))]++;
}
for (int i = 0; i < s2.length(); i++) {
cache[Character.getNumericValue(s2.charAt(i))]--;
}
for (int i = 0; i < 100; i++) {
counter += Math.abs(cache[i]);
}
return counter;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s1 = in.next();
String s2 = in.next();
int result = makingAnagrams(s1, s2);
System.out.println(result);
}
}