7. Intersection with Duplicates
Easy
Given two arrays, return the values present in both, respecting the occurrence count of the array with fewer repetitions. The answer should be in ascending order.
Example 1
Input: a = [1,2,2,3], b = [2,2,4]
Output: [2,2]
Example 2
Input: a = [7,1], b = [2,7,7]
Output: [7]
Constraints
- 0 <= a.length, b.length <= 10000
ArraysHash map
Saved in this browser
Caso 1
a =
[1,2,2,3]
b =
[2,2,4]
Expected =
[2,2]
Caso 2
a =
[7,1]
b =
[2,7,7]
Expected =
[7]
Run checks these 2 cases. Submit runs all 6, including hidden ones.