Thursday, April 16, 2015

HackerRank::Contests::ProjectEuler::Project Euler #11: Largest product in a grid

   Simple brute force is enough, although we might want to keep everything as short as possible. First of all for avoiding extra border check-ups I suggest to create a layer of depth 3, in other words keep an array of size 26x26 where the actual numbers will be from 4x4 to 23x23 and the rest will be just pure 0s. Next, we need to loop over all the numbers and check 8 type of adjacent numbers (left, right, up ,down, left-up, left-down, right-up, right-down), but clearly we can only do the half of the checks (right, down, right-down, right-up).



No comments:

Post a Comment