Search
⌘K

Leetcode 2906. Construct Product Matrix

Given an n×m grid, produce p where p[i][j] is the product of all grid elements except grid[i][j], taken modulo 12345. With up to 1e5 elements, the key is to output all values in linear time by precomputing total product and zero counts (or using prefix/suffix products), noting 12345 is not prime so modular inverses may not always apply.


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.