C# Frog River One
static int FrogRiverOne(int x, int[] a)
{
var existing = new HashSet<int>();
for (int k = 0; k < a.Length; k++)
{
var i = a[k];
if (i <= x && existing.Add(i) && existing.Count == x)
{
return k;
}
}
return -1;
}
This tracks the earliest time each needed position appears and stops as soon as the frog can cross.