Intersection of Two Arrays Solution - The Coding Shala
Home >> Interview Questions >> Intersection of two arrays
Intersection of Two Arrays Solution
In this post, you will learn how to find the intersection of two arrays and its solution in Java.
Given two arrays, write a function to compute their intersection.
Input: nums1 = [1,2,2,1], nums2 = [2,2]
Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
Note: Each element in the result must be unique. The result can be in any order.
Java Program to find the Intersection of Two Arrays
We can find the intersection of two arrays using two HashSets.
Other Posts You May Like
- Median of Two Sorted Arrays
- Remove Duplicates from Sorted Array
- Max Non-Negative Subarray
- Max sum Contiguous Subarray
- Two Sum Problem