Java Frog River One
public class Solution {
    public static int frogRiverOne(int x, int[] a) {
        boolean[] existing = new boolean[x + 1];
        int count = 0;

        for (int k = 0; k < a.length; k++) {
            int i = a[k];
            if (i <= x && !existing[i]) {
                existing[i] = true;
                count++;
                if (count == x) {
                    return k;
                }
            }
        }

        return -1;
    }
}

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