Given two integer arrays A[] and B[] respectively, Write a program to find the intersection of these two arrays.

Problem Note

  • The intersection of two arrays is a list of distinct numbers which are present in both the arrays.
  • Each element in the result must be unique.
  • The result can be in any order.

Example 1

Input: A[] = [1,2,2,1], B[] = [2,2]
Output: [2]

Example 2

Input: A[] = [4,9,5], B[] = [9,4,9,8,4]
Output: [9,4]