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.
Despite using the hashmap and maintaining the frequency of each element and sorting the output array, the test case is not being passed
Code https://ide.codingblocks.com/s/118313
