Solution: A List as a Subset of Another List
Let’s solve the A List as a Subset of Another List problem.
Statement
Given two lists, list1
and list2
, implement a function that takes the two lists as input and checks whether list2
is a subset of list1
.
A subset is a set containing only elements present in another set.
Constraints:
-
list1.length
-
list2.length
list1.length
-
list1[i]
,list2[i]
- All the numbers of
list1
andlist2
are unique
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.