DEV Community

loading...

Discussion on: Daily Challenge #228 - Best Profit in Single Sale

Collapse
aminnairi profile image
Amin

Elm

import List.Extra


maxProfit : List Int -> Int
maxProfit =
    List.Extra.uniquePairs
        >> List.map (\(a, b) -> b - a)
        >> List.maximum
        >> Maybe.withDefault 0