LeetCode 304. Range Sum Query 2D - Immutable | JSer - JavaScript & Algorithm

preview_player
Показать описание
to sum up sub area of a 2D matrix or 1D array, think about subtracting the sum originating at (0,0)
sum(i, j, k, l) = sum(0, 0, k, l ) - sum(0, 0, k, l - 1) - sum(0, 0, i - 1, l) + sum (0, 0, i - 1, j - 1)

Caching of each sum from (0, 0) would be obvious to us

Hi I'm a JavaScript engineer who is not good at algorithms,
and currently practicing leetCode online. If you are interested, maybe we can learn together.
Рекомендации по теме
join shbcf.ru