Prefix Sum | C++
\nclass Solution {\npublic:\n    vector<vector<int>> rangeAddQueries(int n, vector<vector<int>>& queries) {\n        vector<vector<int>> mat(n, vector<int>(n, 0
```\nclass Solution {\npublic:\n    vector<vector<int>> rangeAddQueries(int n, vector<vector<int>>& queries) {\n        vector<vector<int>> mat(n, vector<int>(n, 0));\n        \n        for (auto q : queries) {\n            int r1 = q[0], c1 = q[1], r2 = q[2], c2 = q[3];\n            \n            mat[r1][c1] += 1;\n            if(r2 + 1 < n && c2 + 1 < n) mat[r2 + 1][c2 + 1] += 1;\n            if(r2 + 1< n) mat[r2 + 1][c1] -= 1;\n            if(c2 + 1 < n) mat[r1][c2 + 1] -= 1;\n        }\n        \n        for(int i=0; i<n; i++) {\n            for (int j=1; j<n; j++) {\n                mat[i][j] += mat[i][j - 1];\n            }\n        }\n        for(int i=1; i<n; i++) {\n            for (int j=0; j<n; j++) {\n                mat[i][j] += mat[i - 1][j];\n            }\n        }\n        return mat;\n    }\n};\n```
['Prefix Sum', 'C++']