In 1-D we can find sum in range [l, r] using sum[r] - sum[l - 1].
In 2-D we can find sum in range from (x1, y1) to (x2, y2) using sum[x2][y2] - sum[x2][y1] - sum[x1][y2] + sum[x1][y1] where sum[] or sum[][] is cumulative sum .
How to find sum in range from (x1, y1, z1) to (x2, y2, z2) in a similar way ?