HackerRank in a String!

  • + 0 comments

    Haskell

    module Main where
    
    import Control.Monad (replicateM_)
    
    solve :: String -> String
    solve = go "hackerrank"
      where
        go [] _ = "YES"
        go _ [] = "NO"
        go (x : xs) (y : ys)
          | x == y = go xs ys
          | otherwise = go (x : xs) ys
    
    main :: IO ()
    main = do
      n <- readLn :: IO Int
      replicateM_ n $ getLine >>= putStrLn . solve