Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Check Subset
EASY
18 mins
42 upvotes
Arrays
Topics (Covered in this problem)
Problem solved
Badge
Skill meter
Arrays
-
-
Other topics
Problem solved
Badge
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
Linked List
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
userLevel
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

Check Subset

Contributed by
Ashwani
Easy
yellow-spark
0/40
Avg time to solve 18 mins
Success Rate 90 %
Share
42 upvotes

Problem Statement

You are given two integer arrays ARR1 and ARR2 of length N and M respectively. You have to return true if ARR2 is a subset of ARR1, otherwise, return false.

For Example:

If the given arrays are [1, 2, 3] and [1, 2] then you need to return true as ARR2 is a subset of ARR1, but if the given arrays are [1, 2, 3] and [1, 2, 2] then you need to return false since ARR2 is not a subset of ARR1.
Detailed explanation ( Input/output format, Notes, Constraints, Images )
Sample Input 1:
2
4
1 2 4 6
3
1 2 6
5
9 3 6 5
3
1 3 3
Sample Output 1:
true
false
Explanation For Sample Input 1:
For the first test case:
Here, all the elements of ARR2 are present in ARR1.

For the second test case:
All the elements of ARR2 are not present in ARR1, because there are two 3 in the ARR2 but only a single 3 in ARR1.
Sample Input 2:
2
3
2 3 4
2
4 3
4 
4 4 2 4
4
2 4 5 3
Sample Output 2:
true
false
Reset Code
Full screen
Auto
copy-code
Console