Arrays intersection of two arrays

i m not able to think how to put same key value twice in hashmap so that out for the given test case in the question comes to be [1,1,2,2,3]

Hey @vikashkmr519,
You needn’t use a hashmap for this. You can use a Hashset. Put all elements of array 1 in a hashset. And search element wise for array 2 elements in the hashset.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.