arr2
is considered a subset of another array arr1
if all elements in arr2
are also present in arr1
.arr1 = {1, 2, 3, 4, 5}
arr2 = {3, 4, 5}
Output: Yes, arr2
is a subset of arr1
.arr1 = {1, 2, 3, 4, 5}
arr2 = {1, 2, 9}
Output: No, arr2
is not a subset of arr1
.arr2
using an outer loop.arr2
, check if it exists in arr1
using an inner loop.arr2
are found in arr1
, return true
. Otherwise, return false
.n
, and inner loop for m
.arr1
(larger array).arr2
exists in the sorted arr1
.arr1
and arr2
.arr2
are found in arr1
, return true
.arr1
into a hash set.arr2
and check if each element exists in the hash set.