P15799 [GESP202603 Level 5] Find Numbers
Background
Related multiple-choice and true/false questions: .
Description
Given an array $A$ containing $n$ distinct positive integers and an array $B$ containing $m$ distinct positive integers, please help calculate how many numbers appear in both array $A$ and array $B$.
Input Format
The first line contains two integers $n, m$.
The second line contains $n$ positive integers $a_1, a_2, \cdots, a_n$ representing array $A$.
The third line contains $m$ positive integers $b_1, b_2, \cdots, b_m$ representing array $B$.
Output Format
Output one integer, representing the number of values that appear in both array $A$ and array $B$.
Explanation/Hint
### Sample Explanation
In Sample 1, $4$ and $3$ appear in both arrays $A$ and $B$.
### Constraints
For $40\%$ of the testdata, it is guaranteed that $1 \leq n, m \leq 1000$.
For $100\%$ of the testdata, it is guaranteed that $1 \leq n, m \leq 10^5$, $1 \leq a_i, b_i \leq 10^9$.
Translated by ChatGPT 5