Intersection Of Two_array

easy
1.Take an input N, the size of array.
2.Take N more inputs and store that in an array.
3.Take an input M, the size of array.
4.Take M more inputs and store that in an another array.
Write a function which returns the intersection of two arrays in an ArrayList of integers. Print the ArrayList returned.

Input Format

An input N n1 n2 .. N elements An input M m1 m2 .. M elements

Output Format

An ArrayList

Constraints

N and M cannot be Negative.
0 <= N,M <= 10^9
-10^9 <= Arr[i] <= 10^9

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
5
1
2
3
1
4
5
2
1
3
1
2
Output
[1, 1, 2, 3]
Previous
Intersection Of Two Array
Next
Divisor_game

Related Questions