forked from sknsht/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.java
30 lines (24 loc) · 800 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
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String a = in.nextLine();
String b = in.nextLine();
in.close();
HashMap<Character, Integer> map = new HashMap<>();
int difference = 0;
for (char letter : a.toCharArray()) {
map.put(letter, map.getOrDefault(letter, 0) + 1);
}
for (char letter : b.toCharArray()) {
if (!map.containsKey(letter) || map.get(letter) == 0)
difference++;
else
map.put(letter, map.get(letter) - 1);
}
for (char letter : map.keySet()) {
difference += map.get(letter);
}
System.out.println(difference);
}
}