Challenge: An Array as a Subset of Another Array

Try to solve the An Array as a Subset of Another Array problem.

We'll cover the following


Given two arrays, array1 and array2, implement a function that takes the two arrays as input and checks whether array2 is a subset of array1.

A subset is a set containing only elements present in another set.


  • 11 \leq array1.length 103\leq 10^{3}
  • 00 \leq array2.length \leq array1.length
  • 10310^{-3} \leq array1[i] , array2[i] 103\leq 10^{3}
  • All the numbers of array1 and array2 are unique


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