Skip to content

Instantly share code, notes, and snippets.

@rhaseven7h
Created July 21, 2016 06:03
Show Gist options
  • Save rhaseven7h/5d66bb409e2e4f86e7e3370490464ceb to your computer and use it in GitHub Desktop.
Save rhaseven7h/5d66bb409e2e4f86e7e3370490464ceb to your computer and use it in GitHub Desktop.
HackerRank - Functional Programming - Haskell - Remove Duplicate Characters From String
---- Remove Duplicates and return characters in the order they were found
import Data.List
solve :: String -> String -> String
solve b "" = b
solve b (s:st)
| isInfixOf (s : "") b = solve b st
| otherwise = solve (s : b) st
main = do
line <- getContents
putStrLn $ reverse $ solve "" line
acaaabbacbacbbacccbbbaccbacbbcabcba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment