Minimum Absolute Difference in an Array

  • + 0 comments

    Haskell

    module Main where
    
    import Data.List (sort)
    
    solve :: [Integer] -> Integer
    solve = minimum . map abs . (zipWith (-) <*> tail) . sort
    
    main :: IO ()
    main = getLine >> getLine >>= print . solve . map read . words