Lisp Frog River One
(defun frog-river-one (x a)
(let ((existing (make-hash-table)))
(loop for k from 0
for i in a
do (when (and (not (gethash i existing)) (<= i x))
(setf (gethash i existing) i)
(when (= (hash-table-count existing) x)
(return-from frog-river-one k))))
-1))
This tracks the earliest time each needed position appears and stops as soon as the frog can cross.