Rust Frog River One
use std::collections::HashSet;

fn frog_river_one(x: i64, a: &[i64]) -> i64 {
    let mut existing: HashSet<i64> = HashSet::new();
    for (k, &i) in a.iter().enumerate() {
        if i <= x && existing.insert(i) && existing.len() as i64 == x {
            return k as i64;
        }
    }

    -1
}

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