Problem Description
Given two integer arrays, A and B of size N and M, respectively. Your task is to find all the common elements in both the array.
NOTE:
1 <= N, M <= 105
1 <= A[i] <= 109
First argument is an integer array A of size N.
Second argument is an integer array B of size M.
Return an integer array denoting the common elements.
Input 1:
A = [1, 2, 2, 1] B = [2, 3, 1, 2]
Input 2:
A = [2, 1, 4, 10] B = [3, 6, 2, 10, 10]
Output 1:
[1, 2, 2]
Output 2:
[2, 10]
Explanation 1:
Elements (1, 2, 2) appears in both the array. Note 2 appears twice in both the array.
Explantion 2:
Elements (2, 10) appears in both the array.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.