I have a list of numbers like this (array)
1 2 3 4
So my goal is the check given another array if this array if a permutation of the origin
If you definitely have a sequence you may check if a given array is its permutation much faster. Just calculate a sum of all element of your sequence and compare it with a sum of elements in the given array.
bool is_permutation(vector &v, vector &s) {
// size of the sequence
int v_size = v.size();
// size of probable permutation.
int s_size = s.size();
// Calculate a sum of all elements of the sequence
int sum_of_sequence = (v_size * (1 + v_size)) / 2;
// Count actual sum of elements
int sum_of_all_elements = std::accumulate(v.begin(), v.end(), 0);
// If the sums are equal the array contains a permuted sequence
return sum_of_sequence == sum_of_all_elements;
}