unable to understand how to make update in 3d matrix and how to query in same and whats in the BIT matrix
Sir , Any hint for this que
P.S, here I will give a hint on how we would have done the problem for 2D matrix, understand and try to think of analogically for 3D.
Let r1 = least significant set bit in i, and r2 = least significant set bit in j,
BIT[i][j] = Sum of the block [{i-2^r1+1,j-2^r2+1}, {i,j}]
where sum of block [{x1,y1},{x2,t2}] means sum of the rectangle with top left cell {x1,y1}, and bottom right corner as {x2,y2}.
Yes, it would be highly overwhelming to look at ones, but read it again and again, and try to relate it to the basic definition of BIT[i], believe me, it isn’t as complicated as it seems at first. It is also very easy and intuitive to code.
Also, ones you make this type of BIT, both query and updates are efficiently handled.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.