Intersection of 2 arrays using hashmap

sir I tried this question but I am getting wrong output using hashmap . link:https://ide.codingblocks.com/s/123965

@khushi91200 I can see that your format of output is wrong. It should be [1, 1, 2, 2, 3] but your code is giving output as [2,1,3,1,2,]. So sort the result and remove the last comma .

that is only the thing i am confused how to sort and remove the last comma??

@khushi91200 Instead of directly printing the result as in line 36, push it into a vector. Then sort it separately. After sorting, print the elements of the vector.