String Construction
Solutions Intuition: we only pay the number of distinct letters in s. The rest can be copied.
Thus, the solution consists in simply counting the number of distinct characters in s.
Haskell Just use Set to count unique characters.
1 2 3 4 5 6 7 8 9 import qualified Data.Set as Set import Data.List (intercalate) calculateCost = length . Set.fromList main = do _ <- getLine contents <- getContents putStrLn .
[Read More]