EASY CPP SOLUTION
Approach \nTry reverse order of queries.\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity:O(n)\n Add your time complexity he
# Approach \nTry reverse order of queries.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n        #define ll long long\n    long long matrixSumQueries(int n, vector<vector<int>>& queries) {\n            ios_base::sync_with_stdio(false);\n            cin.tie(NULL);\n            ll ans = 0;\n            vector<bool>row(n),col(n);\n            ll size = n*n;\n            ll colu=0,rowu=0;\n            for(int i=queries.size()-1;i>=0;i--){\n                    int type = queries[i][0];\n                    if(type==0){\n                            if(row[queries[i][1]]==false){\n                                    ll op = n-colu;\n                                    ans+=(1LL*queries[i][2]*op);\n                                    rowu++;\n                                    row[queries[i][1]]=true;\n                            } \n                    }else{\n                            if(col[queries[i][1]]==false){\n                                   ll op = n-rowu;\n                                   ans+=(1LL*queries[i][2]*op);\n                                   colu++; \n                                   col[queries[i][1]]=true;\n                            }\n                    }\n            }\n            return ans;\n    }\n};\n```
['Matrix', 'C++']