forked from sandeep-exe/Hello-Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMatchMacking.java
80 lines (65 loc) · 1.91 KB
/
MatchMacking.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package AdobeMockTest;
import DSAUDemy.Graph.graphTraversal;
import java.util.*;
import java.util.Objects;
class ExpertGroup {
String expert;
String language;
ExpertGroup(String expert, String language) {
this.expert = expert;
this.language = language;
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (o == null || o.getClass() != this.getClass()) return false;
ExpertGroup other = (ExpertGroup) o;
return (
this.expert.equals(other.expert) && this.language.equals(other.language)
);
}
@Override
public int hashCode() {
return Objects.hash(expert, language);
}
}
public class MatchMacking {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
HashMap<ExpertGroup, Integer> groups = new HashMap<ExpertGroup, Integer>();
for (int i = 0; i < 4; i++) {
String str[] = sc.nextLine().split(" ");
ExpertGroup grp = new ExpertGroup(str[0], str[1]);
groups.put(grp, groups.getOrDefault(grp, 0) + 1);
}
HashMap<ExpertGroup, Integer> customers = new HashMap<ExpertGroup, Integer>();
for (int i = 0; i < 4; i++) {
String str[] = sc.nextLine().split(" ");
ExpertGroup grp = new ExpertGroup(str[0], str[1]);
customers.put(grp, customers.getOrDefault(grp, 0) + 1);
}
/*
tax spanish
tax spanish
tax english
crypto hindi
crypto english
tax english
sf spanish
sf spanish
*/
int ans = 0;
for (Map.Entry<ExpertGroup, Integer> entry : customers.entrySet()) {
if (
groups.containsKey(entry.getKey()) && groups.get(entry.getKey()) != 0
) {
groups.replace(entry.getKey(), entry.getValue() - 1);
} else if (!groups.containsKey(entry.getKey())) {
ans += entry.getValue();
} else {
ans++;
}
}
System.out.println(ans);
}
}