public
Created

  • Download Gist
firstNonRep.hs
Haskell
1 2 3 4 5 6 7
import qualified Data.HashMap.Lazy as M -- from unordered-containers
 
firstNonRep :: String -> Char
firstNonRep =
head . M.keys . M.filter (==1) . M.fromListWith (+) . map (\c -> (c,1))
 
main = print $ firstNonRep "aabcbcdeef" == 'd'

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.