C++||Most Easy Greedy Solution by Reverse Iteration
\nclass Solution {\npublic:\n    typedef long long ll;\n    long long matrixSumQueries(int n, vector<vector<int>>& queries) {\n        reverse(queries.begin(),q
```\nclass Solution {\npublic:\n    typedef long long ll;\n    long long matrixSumQueries(int n, vector<vector<int>>& queries) {\n        reverse(queries.begin(),queries.end());\n        unordered_set<ll> row,col;\n        ll cntr=0,cntc=0;\n        ll ans=0;\n        for(auto it:queries)\n        {\n            int type=it[0];\n            int ind=it[1];\n            int val=it[2];\n            if(type==0)\n            {\n                if(row.find(ind)==row.end())\n                {\n                row.insert(ind);\n                ans+=(n-cntc)*val*1LL;\n                cntr++;\n                }\n            }\n            if(type==1)\n            {\n                 if(col.find(ind)==col.end())\n                 {\n                     col.insert(ind);\n                    ans+=(n-cntr)*val*1LL;\n                    cntc++;\n                 }\n            }\n        }\n        return ans;\n    }\n};\n```
[]