Using Sets (Beats 89%)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n1) One cannot build a matrix and perform the operations , Time limit will exceed\n2) 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n1) One cannot build a matrix and perform the operations , Time limit will exceed\n2) Traverse through the queries in reverse order and ensure that the row or column once visited will not be considered in subsequent queries. \n3) Use hashing (can use list as well) to check and compare whether the row or column is already visited. \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(queries Length)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution(object):\n    def matrixSumQueries(self, n, queries):\n        """\n        :type n: int\n        :type queries: List[List[int]]\n        :rtype: int\n        """\n        self.summer = 0 \n        row = set()\n        column = set()\n        for types,index,val in queries[-1::-1]:\n            if types == 0 and index not in row:\n                counter = n - len(column)\n                self.summer += val*counter\n                row.add(index)\n            elif types == 1 and index not in column :\n                count = n - len(row)\n                self.summer += count *val \n                column.add(index)\n        \n        return self.summer\n        \n```
['Python']