Created
July 21, 2016 06:03
-
-
Save rhaseven7h/5d66bb409e2e4f86e7e3370490464ceb to your computer and use it in GitHub Desktop.
HackerRank - Functional Programming - Haskell - Remove Duplicate Characters From String
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
acb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
acaaabbacbacbbacccbbbaccbacbbcabcba |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment