The code is running fine but the three test cases are not being passed.
Question
Take as input N, the size of array. Take N more inputs and store that in an array. Take N more inputs and store that in another array. Write a function which gives the intersection of two arrays in an ArrayList of integers and Print the ArrayList.
Constraints:
Length of Arrays should be between 1 to 1000.
Sample Input:
7
1 2 3 1 2 4 1
2 1 3 1 5 2 2
Sample Output:
[1, 1, 2, 2, 3]
Explanation:
Check which integer is present in both the arrays and add them in an Arraylist .Print ArrayList as the ans.
Code