Matching Pairs
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
1 <= len(a), len(b) <= 20
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Mean of Each GroupMedium
- Multiplication TableMedium
- Order by ScoreMedium
- Pairs Hitting TargetMedium
- Pairwise SumsMedium
- Path LengthMedium
- Rank of Each ScoreMedium
- Ranks Without GapsMedium