I want to determine whether a list A
contains all the elements in the list B
(including duplicate elements).
For example, for A = {1, 1, 1, 3, 3}; B = {1, 1, 1, 3, 3, 3}
should return False
.
For A = {1, 1, 1, 3, 3}; B = {1, 1, 1, 3}
should return True
.
For A = {3, 3, 1, 1, 1}; B = {1, 1, 1, 3}
should return True
.
For A = {3, 3, 1, 1, 4}; B = {1, 1, 4, 4}
should return False
.
What can I do to solve this problem succinctly?
SubsetQ[{3, 3, 1, 1, 4}, {1, 1, 4, 4}](*the result is True, which does not meet the requirements*)
In addition, I'd like to know what other ways to get the index of an array:
SeedRandom[1234]
RandomSample[Array[x, 10]]
% /. _[x_] :> x(*Besides this method, I would like to know as many methods as possible*)