I am trying to find a simple way to check whether a vector is a subset of another without sorting the order of elements in the vector. Both the vectors contain random number
Copy the vectors. Sort the copies. Then use std::includes on the copies.
std::includes
template bool IsSubset(std::vector A, std::vector B) { std::sort(A.begin(), A.end()); std::sort(B.begin(), B.end()); return std::includes(A.begin(), A.end(), B.begin(), B.end()); }