Sum of Matrix After Queries Solution || Time Complexity  O(N)
\nclass Solution {\npublic:\n    long long matrixSumQueries(int n, vector<vector<int>>& queries) {\n        vector<int> rowUsed(n,0);\n        vector<int> colUs
```\nclass Solution {\npublic:\n    long long matrixSumQueries(int n, vector<vector<int>>& queries) {\n        vector<int> rowUsed(n,0);\n        vector<int> colUsed(n,0);\n        int countRowsUsed=0,countColsUsed=0;\n        int sz=queries.size();\n        long long res=0;\n        for(int q=sz-1;q>=0;q--){\n            int type=queries[q][0];\n            if(type==0){\n                int rowIdx=queries[q][1];\n                if(rowUsed[rowIdx]==0){\n                    rowUsed[rowIdx]=1;\n                    countRowsUsed++;\n                    res+=((n-countColsUsed)*queries[q][2]);\n                }\n            }\n            else{\n                int colIdx=queries[q][1];\n                if(colUsed[colIdx]==0){\n                    colUsed[colIdx]=1;\n                    countColsUsed++;\n                    res+=((n-countRowsUsed)*queries[q][2]);\n                }\n            }\n        }\n        return res;\n    }\n};\n```
['Array', 'C']