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.

  1. Use an Object to map all elements of arrB.
  2. Check if every element of arrA exists in that map.
  3. Print true or false.

01EXAMPLE 1

InputarrA=[1, 2], arrB=[1, 2, 3]
Outputtrue

Explanation: 1 and 2 are in B.

Constraints

  • O(n+m) time using Hashing.
ArraysHashing
JavaScript
Loading...
1 Hidden

Input Arguments

arrA[1,2]
arrB[1,2,3]

Expected Output

true

Click RUN to test your solution