108: bring out your hate

Jan 14, 2009 16:01


I just saw that pmb wrote about this problem already, but I haven't looked at his solution. Problem 108 is a straightforward dynamic programming problem. Unfortunately, dynamic programming is pretty novel to me and I'm not finding it particularly straightforward. The examples I've read make sense, more or less, I can't seem to get my head around the recursion well enough to extend it to novel situations (primarily recognizing when the subproblems actually offer you information towards your global solution). In this case, I happened to run across an example for the maximal contiguous subset of a 1D array, so extending it by brute force to a 2D was easy, if unsatisfying. I tested it it to D=16; dunno if it will crap out on bigger arrays.

Will study Peter's example and hopefully start to corral these slippery concepts.

My solution.
Previous post Next post
Up