The Subset Audit
EasyAcc. 98.1%
+15 XP 5
Structural Membership
Array A is a subset of Array B if every element in A exists at least once in B.
The Assignment
Your function receives arrA and arrB.
- Use an Object to map all elements of
arrB. - Check if every element of
arrAexists in that map. - Print true or false.
01EXAMPLE 1
Input
arrA=[1, 2], arrB=[1, 2, 3]Output
trueExplanation: 1 and 2 are in B.
Constraints
- O(n+m) time using Hashing.
ArraysHashing
JavaScriptSystem handles I/O — write your function only
Loading...
1 Hidden
Input Arguments
arrA[1,2]
arrB[1,2,3]
Expected Output
true
Click RUN to test your solution