PermMissingElem

Find the missing element in a given permutation.

Here my solution in C++

int solution(vector<int> &A) { long long sum = 0; for ( const auto &item : A) sum += item; long long sum_tot = ((A.size() + 1) * (A.size() + 2)) /2; return int (sum_tot-sum); }
Comments