Can someone tell me a good editorial or any best approach to solve this hackerrank problem?
This problem is just asking you to perform range updates and range queries in two dimensions, where every range is a rectangle. There are many ways to solve this, but as far as I know, the easiest (to implement) is using a 2D BIT/Fenwick tree. Read this if you don’t already know what a BIT is :
And then, read this to understand how the 2D version works :
You can find the editorial here:
I knew about this and have already seen the editorial, but still I’m having a difficulty in understanding the approach that they used in editorial and how they are performing sub-matrix update in \log n time ?