easy to understand || must see
Code\n\nclass Solution \n{\npublic:\n    vector<vector<int>> rangeAddQueries(int n, vector<vector<int>>& queries) \n    {\n        vector<vector<int>>mat(n,vect
# Code\n```\nclass Solution \n{\npublic:\n    vector<vector<int>> rangeAddQueries(int n, vector<vector<int>>& queries) \n    {\n        vector<vector<int>>mat(n,vector<int>(n,0));\n\n        //preprocessing\n        for(int i=0;i<queries.size();i++)\n        {\n            //row col  row col\n            int startrow = queries[i][0];\n            int endrow   = queries[i][2];\n            \n            int startcol = queries[i][1];\n            int endcol   = queries[i][3];\n\n            for(int j=startrow;j<=endrow;j++)\n            {\n                mat[j][startcol]+=1;\n            }\n            if(endcol+1 < mat[0].size())\n            {\n               for(int j=startrow;j<=endrow;j++)\n               {\n                    mat[j][endcol+1]-=1;\n               }   \n            }\n        }    \n\n        //linear accumulation\n        for(int i=0;i<mat.size();i++)\n        {\n            for(int j=0;j<mat[i].size();j++)\n            {\n                if(j == 0)\n                continue;\n\n                mat[i][j] = mat[i][j] + mat[i][j-1];\n            }\n        }\n        return mat;        \n    }\n};\n```
['Array', 'Matrix', 'Prefix Sum', 'C++']