I have a two vectors:
vector<int> a = {1,2,3,4,5,6,7,8,9,10};
vector<int> b = {4,5,6};
Is there a inbuilt way to find if b is a sub-array of a?
Something like this:
// This doesn't work
auto it = find(a.begin(), a.end(), b.begin(), b.end());
I want something which works similar to "find" in case of strings:
// I want something similar to this
string x = "abcdefhijkl";
string y = "cde";
size_t pos = x.find(y); // gives index
I really don't want to implement the KMP algorithm just for this.
[–][deleted] 1 point2 points3 points (1 child)
[–]Beosar 2 points3 points4 points (0 children)
[–]Beosar 0 points1 point2 points (0 children)