✅Simple C# Solution || Difference array || Beats 100%✅
The first step is to create a 2D array called arr with n rows and n columns, filled with zeroes.\n\nThen, it iterates over the queries, for each query, it adds 
The first step is to create a 2D array called arr with n rows and n columns, filled with zeroes.\n\nThen, it iterates over the queries, for each query, it adds +1 to the specific position in the array and -1 to the next column if it\'s less than n. This is done to mark the range of the query, the first element of the range will be incremented by one, and the next element after the range will be decremented by one. This way, the difference between the two elements will be the value that is added to the range.\n\nThen, it iterates over the array, for each element of the array, it adds the current element to the previous one, this is done to convert the marked array to the final array.\n\nThis approach is similar to the difference array algorithm, as it\'s using the same technique to solve the problem, it\'s updating the range by marking it with +1 and -1 and then converting it to the final array by adding up the current element to the previous one.\n\nThe time complexity of this solution is $$O(n^2)$$ as we are iterating over the array multiple times and the space complexity is $$O(n^2)$$ as we are using a 2D array with n*n elements.\n# Approach\nDifference array\n\n# Complexity\n- Time complexity: $$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n^2)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\npublic class Solution {\n    public int[][] RangeAddQueries(int n, int[][] queries) {\n        var arr = new int[n][];\n        for (var i = 0; i < n; i++)\n        {\n            arr[i] = new int[n];\n        }\n\n        for (var i = 0; i < queries.Length; i++)\n        {\n            var row1 = queries[i][0];\n            var row2 = queries[i][2];\n            var col1 = queries[i][1];\n            var col2 = queries[i][3];\n            for (var j = row1; j <= row2; j++)\n            {\n                arr[j][col1]++;\n                if (col2 + 1 < n) arr[j][col2+1]--;\n            }\n        }\n\n        for (var i = 0; i < n; i++)\n        {\n            for (var j = 1; j < n; j++)\n            {\n                arr[i][j] += arr[i][j-1];\n            }\n        }\n\n        return arr;\n    }\n}\n```
['C#']