DEV Community

Discussion on: Daily Challenge #159 - Isogram

Collapse
 
craigmc08 profile image
Craig McIlwrath

Haskell

import Data.Char (toLower)

noDuplicates :: (Eq a) => [a] -> Bool
noDuplicates [] = True
noDuplicates (x:xs) = not (x `elem` xs) && noDuplicates xs

isIsogram :: String -> Bool
isIsogram = noDuplicates . map toLower

I think the complexity of this method is O(n2), but it shouldn't matter too much since the since && can exit early, so the maximum number of iterations can only be 26 (by the pigeonhole principle).