Haskell Missing Integer
import qualified Data.Set as Set
missingInteger :: [Int] -> Int
missingInteger a = go 1 (Set.toAscList (Set.fromList (filter (> 0) a)))
where
go m [] = m
go m (v : vs)
| m /= v = m
| otherwise = go (m + 1) vs
This records the positive numbers that exist, then returns the smallest positive value that is still missing.