✅📌 || Brute force accepted in JAVA || Beginner friendly || Space complexity explained
Intuition\n Describe your first thoughts on how to solve this problem. \nBrute force\n\n\n\n# Complexity\n- Time complexity:\n Add your time complexity here, e.
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBrute force\n\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(Q*(N*N))$$\nwhere Q is queries length\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(N*N)$$\nI think it was a amortized $$O(1)$$ because we are declaring auxiliary space except the return matrix.\n\ncorrect me if i am wrong. \n\n# Code\n```\nclass Solution {\n    public int[][] rangeAddQueries(int n, int[][] queries) {\n        int[][] mat=new int[n][n];\n\n        for(int[] ar:queries)\n        {\n            int r1=ar[0];\n            int c1=ar[1];\n\n            int r2=ar[2];\n            int c2=ar[3];\n\n            for(int i=r1;i<=r2;i++)\n            {\n                for(int j=c1;j<=c2;j++)\n                {\n                    mat[i][j]++;\n                }\n            }\n        }\n\n        \n        return mat;\n\n    }\n}\n```
['Math', 'Matrix', 'Java']