Challenge: An Array as a Subset of Another Array
Can you find whether a given array is a subset of another array by using a hash table?
We'll cover the following
Problem Statement #
Implement the isSubset(int* arr1, int* arr2, int size1, int size2)
function, which will take two arrays and their sizes as input and check whether one array is the subset of the other.
Note: The input arrays do not contain duplicate values.
Input #
Two arrays of integers and their sizes.
Output #
true
if arr2
is a subset of arr1
.
Sample Input #
arr1 = {9,4,7,1,-2,6,5}
arr2 = {7,1,-2}
size1 = 7
size2 = 3
Sample Output #
true
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.