James,

In my earlier post I mentioned that you should find a dynamic
programming approach to this problem. My solution is presented below,
so you've been warned if you are still working this out:


=== READ ABOVE ===

import Data.List (foldl')

solve = snd . foldl' aux (0, 0)
 where
 aux (cur, best) x = (max 0 cur', max best cur')
   where
   cur' = cur + x


--
Eric Mertens
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to