152ms run time
Intuition\nMy first thoughts were very wrong.  I tried tracking a whole matrix and ran into heap errors, then tried using a Uint32Array because 10^5 > 2^16 befo
# Intuition\nMy first thoughts were very wrong.  I tried tracking a whole matrix and ran into heap errors, then tried using a Uint32Array because 10^5 > 2^16 before realizing I didn\'t need to save an integer at all at which point I saw comments saying to go backwards and I realized I didn\'t even need a matrix.\n\n# Approach\nI used hashmap lookups O(1) to store my values and bailed if a query had been used before, then used math to figure out the total.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```typescript []\n\nfunction matrixSumQueries(n: number, queries: number[][]): number {\n    const rowCol = {\n        0: 0,\n        1: 0\n    };\n    const used = {};\n    let total = 0;\n\n    while (queries.length) {\n        const [type, index, val] = queries.pop();\n        if (used[type + \'_\' + index]) continue;\n        total += (n - rowCol[+!type]) * val;\n        used[type + \'_\' + index] = true;\n        rowCol[type]++;\n    }\n\n    return total;\n};\n\n```
['TypeScript']