All tasks
Mediumhashsetarrays

Common Values of Two Arrays

Time limit 2 s · Memory 64 MBAcceptance: 100.0%Solved by: 1

Statement

The first line contains n, the second line contains n integers. The third line contains m, the fourth line contains m integers. Print how many distinct values occur in both arrays.

Examples

Example 1
Input
4
1 2 3 4
3
3 4 5
Output
2
Example 2
Input
3
1 1 1
2
1 1
Output
1

Constraints

  • 1 ≤ n, m ≤ 10^5
  • -10^9 ≤ a_i, b_i ≤ 10^9
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.