#2956

Find Common Elements Between Two Arrays

easy · 84.4% accepted · 304 likes · top 96%

array · hash table

Description

You are given two integer arrays nums1 and nums2 of sizes n and m, respectively. Calculate the following values:

- answer1 : the number of indices i such that nums1[i] exists in nums2.

- answer2 : the number of indices i such that nums2[i] exists in nums1.

Return [answer1,answer2].

Solution