-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathStrings:MakingAnagrams.java
More file actions
30 lines (28 loc) · 783 Bytes
/
Copy pathStrings:MakingAnagrams.java
File metadata and controls
30 lines (28 loc) · 783 Bytes
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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static int numberNeeded(String first, String second) {
int a[] = new int[26];
int b[] = new int[26];
for(int i=0;i<first.length();i++){
a[first.charAt(i)-97]++;
}
for(int i=0;i<second.length();i++){
b[second.charAt(i)-97]++;
}
int count = 0;
for(int i=0;i<26;i++) {
count += Math.abs(a[i]-b[i]);
}
return count;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String a = in.next();
String b = in.next();
System.out.println(numberNeeded(a, b));
}
}