HINDI VERSION || C++ || EASY APPROACH
The post is in hindi because there are very less post explaning approach in HINDI.\n# Approach\nSirf itni baat yaad rakho ki har query mein starting row se endi
The post is in hindi because there are very less post explaning approach in HINDI.\n# Approach\nSirf itni baat yaad rakho ki har query mein starting row se ending row tak ke starting and ending column ko mark karna hai taaki whole matrix ko ek baar mein fill kar sake. Har query ka last column agar nth column nahi hai toh uske next column par -1 ko mark kardenge taaki ye paata chal jaaye ki yahan ek query finish ho rahi hai. Baaki ek example ko pick karo and uspar dry run karo code ke saath saath and comments provided hai code mein.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(queries*n) + O(n*n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n*n) for result vector\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> rangeAddQueries(int n, vector<vector<int>>& queries) {\n        vector<vector<int>>res(n,vector<int>(n,0));\n        res.resize(n,vector<int>(n,0));\n        int m = queries.size();\n        // Ye loop ki time Complexity hogi : O(queries*n)\n        for(int i=0;i<m;i++)\n        {\n            // ye starting row ka position hai\n            int rowS = queries[i][0];\n            // ye starting column ka position hai\n            int colS = queries[i][1];\n            // ye ending row ka position hai\n            int rowE = queries[i][2];\n            // ye ending column ka position hai\n            int colE = queries[i][3];\n            // ab hum yahan har row ke liye uski starting and ending position mark kar rahe hai ki bhai is row ke is index tak 1 put karna hai\n            for(int j=rowS;j<=rowE;j++)\n            {\n                res[j][colS]++;\n                // ye condition ye bata degi ki kahan par stop karna hai ek given query ke liye toh hum us point par -1 mark kar denge\n                if((colE+1)!=n)\n                {\n                    res[j][colE+1]--;\n                }\n            }\n        }\n        // ye loop ki time complexity hogi O(n*n)\n        // ab hum prefix sum waale concept ka istemal karke pura matrix fill karlenge\n        for(int i = 0; i < n; i++)\n            for(int j = 1; j < n; j++)\n            // columns ke through traverse karke matrix mein previous value ko add karte jaa rahe hai\n                res[i][j] += res[i][j-1];\n        return res;\n    }\n};\n```\nAgar post read karke help mili ho toh please upvote karna!!!
['C++']