C++ Perm Check
#include <algorithm>
#include <cstddef>
#include <vector>
int permCheck(std::vector<int> a)
{
std::sort(a.begin(), a.end());
for (std::size_t k = 0; k < a.size(); ++k) {
if (k + 1 < a.size() && a[k] != static_cast<int>(k) + 1) {
return 0;
}
}
return 1;
}
This validates that every value from 1 to N appears exactly once.