You are viewing a single comment's thread. Return to all comments →
My haskell solution
-- Enter your code here. Read input from STDIN. Print output to STDOUT import Data.List count :: Int -> [Int] -> Int count _ [] = 0 count n (x:xs) | n == x = 1 + count n xs | otherwise = count n xs filterList :: Int -> [Int] -> String filterList n xs | null result = "-1" | otherwise = result where result = unwords $ map show $ nub $ filter (\x -> count x xs >= n) xs solve :: Int -> IO () solve 0 = return () solve n = do [size, k] <- words <$> getLine xs <- words <$> getLine putStrLn $ filterList (read k) (map read xs) solve (n-1) main = do n <- readLn solve n
Seems like cookies are disabled on this browser, please enable them to open this website
Filter Elements
You are viewing a single comment's thread. Return to all comments →
My haskell solution