Haskell Quiz/Maximum Sub-Array/Solution Jkramar
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
maxSubArray xs = drop from$take to xs where
sums = zip (scanl (+) 0 xs) [0..]
diff ((a,ai),(b,bi)) = (a-b,(bi,ai))
(from,to) = snd$maximum$map diff$zip sums$scanl1 min sums