Intersection of Two Arrays II
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given two integer arrays nums1 and nums2, return an array of their intersection.
Unlike a plain set intersection, **each element in the result must appear as many times as it shows up in *both* arrays**. In other words, if a value occurs a times in nums1 and b times in nums2, it should appear exactly min(a, b) times in the output.
The result may be returned in **any order**.
Examples
Constraints
- `1 <= nums1.length, nums2.length <= 1000`
- `0 <= nums1[i], nums2[i] <= 1000`
- The output may be returned in any order.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.