C++ Perm Missing Element
#include <algorithm>
#include <cstddef>
#include <vector>

long long permMissingElement(std::vector<int> a)
{
    std::sort(a.begin(), a.end());

    for (std::size_t k = 0; k < a.size(); ++k) {
        if (a[k] != static_cast<int>(k) + 1) {
            return static_cast<long long>(k) + 1;
        }
    }

    return static_cast<long long>(a.size()) + 1;
}

This uses the expected sum of 1..N+1 and subtracts the actual sum to find the missing value.