Python Frog River One
def frog_river_one(x: int, a: list[int]) -> int:
existing: set[int] = set()
for k, i in enumerate(a):
if i not in existing and i <= x:
existing.add(i)
if len(existing) == x:
return k
return -1
This tracks the earliest time each needed position appears and stops as soon as the frog can cross.