Trains the technique from
LeetCode 2906Construct Product MatrixThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A calibration panel is a grid of n rows by m columns of readings, given as grid.
Build a second grid panel of the same shape, where panel[i][j] is the product of every reading of grid except the one at row i, column j, taken modulo 12345.
Return panel.
Example 1
For the cell holding 4 the other readings are 7, 2 and 5, whose product is 70. For the cell holding 7 they are 4, 2 and 5, giving 40. For 2 they are 4, 7 and 5, giving 140, and for 5 they are 4, 7 and 2, giving 56. All four are below 12345, so the remainder leaves them unchanged.
Example 2
The panel has one column. The cell holding 6 has only the 7 left, and the cell holding 7 has only the 6.
Example 3
For the first cell the remaining product is 4. For the second it is 12345, and 12345 leaves a remainder of 0 on division by 12345.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def cross_product_grid(grid: list[list[int]]) -> list[list[int]]:public int[][] crossProductGrid(int[][] grid)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.