Hacker News new | ask | show | jobs
by jongraehl 3952 days ago
That problem has nothing to do with linear algebra. I like it! Presumably the submatrix size is limited, or there are negative numbers. Personally I'd precompute the submatrix sums S[r,c] for row 1...r and col 1...c in r*c steps, which will then allow you to give the sum for any submatrix in constant time.