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?

Problem Statement

Implement the isSubset(list1,list2) function which will take two arrays 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.

Output

true if list2 is a subset of list1.

Sample Input

var list1 = [9,4,7,1,-2,6,5]
var list2 = [7,1,-2]

Sample Output

true

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.