C++ Frog River One
#include <cstddef>
#include <vector>

int frogRiverOne(int x, const std::vector<int>& a)
{
    std::vector<bool> existing(x + 1, false);
    int count = 0;

    for (std::size_t k = 0; k < a.size(); ++k) {
        int i = a[k];
        if (i <= x && !existing[i]) {
            existing[i] = true;
            ++count;
            if (count == x) {
                return static_cast<int>(k);
            }
        }
    }

    return -1;
}

This tracks the earliest time each needed position appears and stops as soon as the frog can cross.