C++ solution
\n\n\n\n\nclass Solution {\npublic:\n    vector<vector<int>> rangeAddQueries(int n, vector<vector<int>>& queries)\n    {\n        vector<vector<int>> v(n,vector
![image](https://assets.leetcode.com/users/images/3db57d59-9106-49cf-b22b-132d4b9bb4a2_1673760058.2489529.png)\n\n\n\n```\nclass Solution {\npublic:\n    vector<vector<int>> rangeAddQueries(int n, vector<vector<int>>& queries)\n    {\n        vector<vector<int>> v(n,vector<int>(n,0));\n        for(auto i: queries)\n        {\n            int row1=i[0],col1=i[1],row2=i[2],col2=i[3];\n            for(int j=row1;j<=row2;j++)\n                v[j][col1]++;\n            if(col2==n-1)\n                for(int j=row1+1;j<=row2+1 && j<n;j++)\n                    v[j][0]--;\n            else\n                for(int j=row1;j<=row2;j++)\n                    v[j][col2+1]--;\n                \n        }\n        int prev=0;\n        for(int i=0;i<n;i++)\n            for(int j=0;j<n;j++)\n            {\n                v[i][j]+=prev;\n                prev=v[i][j];\n            }\n        return v;\n    }\n};\n```\n\nLogic - I tried to use a 2D implementation of 1D range sum queries.\nTime Complexity: O(queries * rows) for first function, O(rows * columns) for second function.\nSpace Complextity: O(rows * columns)
['C', 'C++']