In this problem we have $n$ boys and $m$ girls, followed by $n$ values $a_1, \dots, a_n$ ($1 \leq a_i \leq n$), where $a_i$ is the skill value of the $i$-th boy. And likewise, there are $m$ values $b_1, \dots, b_m$ ($1 \leq b_j \leq n$), where $b_j$ is the skill value of the $j$-th girl.
We need to find the maximum possible number of pairs that we can make, under the condition that the difference in skill value between a matched boy and girl is no greater than $1$. We can do this using the Hopcroft-Karp maximum matching algorithm.