🔥✅Clean & Best C++ Code✅ ||💯Greedy(Traverse from Back)🔥💯
Complexity\n- Time complexity:\nO(q) where \'q\' is the size of the query\n\n- Space complexity:\nO(n)\n\n# Code\n## Please Upvote if u liked my Solution\uD83E\
# Complexity\n- Time complexity:\nO(q) where \'q\' is the size of the query\n\n- Space complexity:\nO(n)\n\n# Code\n## Please Upvote if u liked my Solution\uD83E\uDD17\n```\nclass Solution {\npublic:\n    long long matrixSumQueries(int n, vector<vector<int>>& queries) {\n        long sum = 0;\n        vector<int> row(n),col(n);\n        int row_visited = 0,col_visited = 0,que_size = queries.size();\n        for(int i=que_size-1;i>=0;i--){\n            int type = queries[i][0],ind = queries[i][1],val = queries[i][2];\n            if((type && col[ind]) || (!type && row[ind]))\n                continue;\n            if(type){\n                sum += (n - row_visited)*val; \n                col_visited++;\n                col[ind] = 1;\n            }\n            else{\n                sum += (n - col_visited)*val; \n                row_visited++;\n                row[ind] = 1;\n            }\n                \n        }\n        return sum;\n    }\n};\n```
['Array', 'Greedy', 'Matrix', 'C++']