32: Arrays intersection 2

Find the intersection of two arrays. Each item in the result should appear as many times as it appears in both arrays

 

Example 1

Input: array1 = [9, 15, 9, 23, 9] array2 = [16, 9, 23, 9]

Output: [9, 23, 9]

Example 2

Input: array1 = [2, 4, 5] array2 = [16, 23, 9]

Output: []
Difficulty:Easy
Topic:HashSet
Problem #:32