I started this blog to post stuff about programming and algorithms but all I've done so far are some Android and Linux tips, which for a programmer who doesn't care about anything but programming, is total garbage. So this is going to be the first post about programming and algorithms.
I'm assuming you have basic knowledge about algorithms and programming and for this specific post some knowledge about arrays, 2D arrays and a little bit of graph theory studies might help. All I/O is done to and from STDIN and STDOUT.
Maximum product of an NxN grid, a 2D array, or a matrix. I've seen this exact problem repeated and repeated so many times in too many algorithmic programming contests with very little changes. You may have to find the sum of a grid, the sum of the absolute values in a grid, and the sum/product of X adjacent values. Which is basically the same thing, loop through the array horizontally, vertically and diagonally find the max, return it.
So this is what we're going to do:
- Initialize the grid with the constraints number.
- Read the array
- Loop horizontally and vertically while comparing to the maximum.
- Loop diagonally.
- Return the maximum.
Leave a comment so I know my time spent on this isn't a total waste. :D
