You are viewing a single comment's thread. Return to all comments →
minimumLoss :: [Int] -> Int minimumLoss prices = let prefixSets :: [S.Set Int] prefixSets = scanl (flip S.insert) S.empty (init prices) nextBiggestBefore :: [Maybe Int] nextBiggestBefore = zipWith S.lookupGT prices prefixSets losses :: [Maybe Int] losses = zipWith (\x y -> (subtract y) <$> x) nextBiggestBefore prices in minimum (catMaybes losses)
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Loss
You are viewing a single comment's thread. Return to all comments →
Haskell