Search
⌘K

Leetcode 2718. Sum of Matrix After Queries

Given an n×n zero matrix and queries that set entire rows or columns (overwriting previous values), compute the final matrix sum. Because later updates override earlier ones, the challenge is to count each query's net contribution efficiently (n up to 10^4, queries up to 5×10^4) by tracking which rows/columns have already been set (e.g., via reverse processing).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.