java.lang.Object
g0301_0400.s0349_intersection_of_two_arrays.Solution

public class Solution extends Object
349 - Intersection of Two Arrays.<p>Easy</p> <p>Given two integer arrays <code>nums1</code> and <code>nums2</code>, return <em>an array of their intersection</em>. Each element in the result must be <strong>unique</strong> and you may return the result in <strong>any order</strong>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums1 = [1,2,2,1], nums2 = [2,2]</p> <p><strong>Output:</strong> [2]</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums1 = [4,9,5], nums2 = [9,4,9,8,4]</p> <p><strong>Output:</strong> [9,4]</p> <p><strong>Explanation:</strong> [4,9] is also accepted.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= nums1.length, nums2.length <= 1000</code></li> <li><code>0 <= nums1[i], nums2[i] <= 1000</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • intersection

      public int[] intersection(int[] nums1, int[] nums2)