Today's problem is checking whether a character array is a subset of another one (when viewed as sets of characters):
Write a function whose first and second inputs are arrays of characters and output is true if every element of the first input is an element of the second input and false otherwise.
For example,
(['t', 'e', 'n', 'n', 'e', 's', 's', 'e', 'e'], ['e', 'n', 's', 't'])
outputs true and
(['h', 'e', 'l', 'l', 'o'], ['a', 'h', 'l', 'e'])
outputs false.
The canonical naïve function runs in O(n * m) time, where n and m are the sizes of the first and second inputs, respectively. Can you write a function that runs in O(n + m) time?