Easy explaination & intution -  0(N) || Easy and simple code
Intuition\nDon\'t worry if you were not able to solve this problem during the contest,\nLets get into the question:\n\nwe have to Return the sum of integers in 
# Intuition\nDon\'t worry if you were not able to solve this problem during the contest,\nLets get into the question:\n\nwe have to **Return the sum of integers in the matrix after all queries are applied ** So, If you observe the if we see the changes made in the **REVERSE ORDER** , then you just need to update the 2d matrix once, if again the same indices appear do not bother about it.\n\nA problem was not how to build an effective algorithm.\n1. Observe the change when a column or a row is added, what changes do we see for the upcoming values.\n\nEverytime a new column or row filled with a given value is added, next time empty places for the upcoming element decreses by 1.\n\n---\nSee:\n        Take a 3X3 matrix all filled with 0,s\n        0 0 0\n        0 0 0\n        0 0 0\nNow lets us add value 1 to the first row:\n        1 1 1\n        0 0 0\n        0 0 0\nNow see for and upcoming values for the column you\'ll have n-1 places to fill it, the same goes vice versa. \n\n\n\n\n      \n\n\n# Approach\n1. Firstly reverse the array.\n2. Initialize a set data structue to keep the track of the row number or the column number for which you have made the changes.\n3. Add to answer val * remaining row when col operation is performed &\nadd to answer val * remaining col when row operation is performed.\n4. Decreament remaining row when row operation is performed &\nreamining col when col operation is performed.\n\n# Complexity\n- Time complexity:\n0(n) where n is the number of queries\n\n- Space complexity:\n0(n) set size where n is the number of indices\n\n# Code\n```\nclass Solution {\npublic:\n    long long matrixSumQueries(int n, vector<vector<int>>& a) {\n        int x = a.size();\n        int row = n,col = n;\n        reverse(a.begin(),a.end()); // Key observaition\n        long long ans = 0;\n        set<pair<int,int>> st;\n        for(int i=0;i<x;i++)\n        {\n            int type = a[i][0];\n            int flag = a[i][1];\n            int val = a[i][2];\n            if(st.find({type,flag})==st.end())\n            {\n                st.insert({type,flag});\n                if(type==0)\n                {\n                    long long temp1 = row*val; // Simple maths\n                    col--;\n                    ans+= temp1;\n                }\n                else if(type==1)\n                {\n                    long long temp2 = col*val;\n                    row--;\n                    ans+= temp2;\n                }\n            }\n            else if(st.find({type,flag})!=st.end())continue;\n        }\n        return ans;\n    }\n};\n```
['C++']