Tap here to switch tabs
Problem
Submissions

Problem: Intersection of Two Arrays II

Intersection of Two Arrays II compares two integer arrays and returns their shared values, including each number as many times as it occurs in both arrays, in any order.

Statement

Given two integer arrays nums1 and nums2, return an array representing their intersection. Each element in the result should appear exactly as many times as it appears in both arrays. The result may be returned in any order.

Constraints:

  • 1≤1 \leq nums1.length, nums2.length ≤1000\leq 1000

  • 0≤0 \leq nums1[i], nums2[i] ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Intersection of Two Arrays II

Intersection of Two Arrays II compares two integer arrays and returns their shared values, including each number as many times as it occurs in both arrays, in any order.

Statement

Given two integer arrays nums1 and nums2, return an array representing their intersection. Each element in the result should appear exactly as many times as it appears in both arrays. The result may be returned in any order.

Constraints:

  • 1≤1 \leq nums1.length, nums2.length ≤1000\leq 1000

  • 0≤0 \leq nums1[i], nums2[i] ≤1000\leq 1000