Easy Solution in Java using Prefix sum!
Complexity\n- Time complexity:\nO(Q\u22C5n+n^2) \n\n- Space complexity:\nO(n^2) \n\n# Code\njava []\nclass Solution {\n    public int[][] rangeAddQueries(int n,
# Complexity\n- Time complexity:\n$$O(Q\u22C5n+n^2)$$ \n\n- Space complexity:\n$$O(n^2)$$ \n\n# Code\n```java []\nclass Solution {\n    public int[][] rangeAddQueries(int n, int[][] queries) {\n        int[][] mat = new int[n][n];\n        for (int q = 0; q < queries.length; q++) {\n            int r1 = queries[q][0];\n            int c1 = queries[q][1];\n            int r2 = queries[q][2];\n            int c2 = queries[q][3];\n            for (int i = r1; i <= r2; i++) {\n                mat[i][c1]++;\n                if ((c2 + 1) < n) {\n                    mat[i][c2 + 1]--;\n                }\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        return mat;\n    }\n}\n```
['Matrix', 'Prefix Sum', 'Java']