FunctionRacerProblemsRace

Matching Pairs

MediumNumPyPython

Count the pairs of positions (i, j) such that a[i] == b[j]. Every combination counts, so if the value 5 appears twice in a and three times in b, that adds 6 pairs. Return an int.

Example 1

a [1,2,2]
b [2,2,3]
returns 4

Each of the two 2s in a matches each of the two 2s in b, giving 4 pairs.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems