Common Elements
Count the elements the two multisets share: for every value, min(count in A, count in B), summed.
Input: the first line has N; the second line has A's N values; the third line has B's N values.
Output: the multiset intersection size.
Constraints:
- 1 ≤ N ≤ 105
- |values| ≤ 109
Sample Tests
Input 1
4 1 2 2 3 2 2 4 1
Output 1
3
Input 2
2 5 6 7 8
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.