Showing:
Handle Score
@Ibrahim Nash 5725
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Intersection of two arrays
Basic Accuracy: 39.21% Submissions: 8432 Points: 1

Given two arrays A and B respectively of size N and M, the task is to print the count of elements in the intersection (or common elements) of the two arrays.

For this question, the intersection of two arrays can be defined as the set containing distinct common elements between the two arrays.

Example 1:

Input:
5 3
89 24 75 11 23
89 2 4

Output:
1

Explanation:
89 is the only element
in the intersection of two arrays.

Example 2:

Input:
6 5
1 2 3 4 5 6
3 4 5 6 7

Output:
4

Explanation:
3 4 5 and 6 are the elements
in the intersection of two arrays.


The task is to complete the function NumberofElementsInIntersection() which takes 4 inputs ie- array a, array b, n which is the size of array a, m which is the size of array b. The function should return the count of the number of elements in the intersection.

Expected Time Complexity: O(N + M).
Expected Auxiliary Space: O(min(N,M)).

Constraints:
1 ≤ N, M ≤ 105
1 ≤ A[i], B[i] ≤ 105