You are viewing a single comment's thread. Return to all comments →
Given the constraint in the question (-9 <= arr[i][j] <= 9 and 0 <= i,j <= 5), I used the possible maximum negative value to initialize my max value (-9 * 6 = -54).
max negative value is -63 (-9 * 7)
anything less than -54.
For python initialize with:
I initialized with 1 << 16 * -1
That would very silly. Why not just use the minimum value of -63 as others have indicated.
This is correct, but the test cases given also had nothing lower than -54, which was lucky for me, since I made the (mindless) error of thinking there were only 6 elements in an hourglass.
One of the test cases should have a max of -62 for this reason, IMO.
This is correct. Given the question the lowest possible sum is -63. The sum of an hourglass is always multiplied by 7 (2 rows of 3 + 1 column of 1). The highest negative number is -9. Therefore -9 * 7 = -63
first value always works and doesn't rely on you knowing the input before execution
yes intitalizing max value less than maximum negative value helped me in solving 3,5,7 testcases