Skip to content
Veltoryx Technologies
ProProblem 9● EasyLeetCode #350 ↗2 min readUpdated 30 October 2026

Intersection of Two Arrays II

Find the common values of two arrays, as many times as they appear in both, by counting one array and using up the counts.

01The problem

Return the values that appear in both nums1 and nums2. Each value appears in the answer as many times as it appears in both (the smaller of the two counts). Any order is fine.

nums1nums2Output
[1, 2, 2, 1][2, 2][2, 2]
[4, 9, 5][9, 4, 9, 8, 4][9, 4]

Loading the rest of the lesson…