TypeScript Frog River One
function frogRiverOne(x: number, a: number[]): number {
  const existing = new Set<number>();

  for (let k = 0; k < a.length; k++) {
    const i = a[k];
    if (!existing.has(i) && i <= x) {
      existing.add(i);
      if (existing.size === x) {
        return k;
      }
    }
  }

  return -1;
}

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