Go Frog River One
func frogRiverOne(x int, a []int) int {
existing := make(map[int]bool)
for k, v := range a {
if v <= x && !existing[v] {
existing[v] = true
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.