Add Two Matrices
Given two nonempty rectangular integer matrices with the same dimensions, return a matrix with the same dimensions whose cell at each coordinate is the sum of…
Given two nonempty rectangular integer matrices with the same dimensions, return a matrix with the same dimensions whose cell at each coordinate is the sum of the two input cells at that coordinate.
Each input has 1 to 1000 rows, 1 to 500 columns, and at most 250,000 cells. Each matrix is rectangular and has the same dimensions as the other. Every cell is an integer from -1000 through 1000. The visualizer uses matrices with at most 6 rows and 6 columns; larger valid inputs are execution-only.
Example 1: input first = [[1, -2], [3, 4]], second = [[5, 7], [-3, 0]]; output [[6, 5], [0, 4]]. Add the two values at each matching coordinate and keep that coordinate in the result.
Example 2: input first = [[-1000, 1000]], second = [[1000, -1000]]; output [[0, 0]]. Opposite boundary values cancel independently in each column.
Example 3: input first = [[7]], second = [[-9]]; output [[-2]]. A one-cell matrix follows the same coordinate-wise rule.
Category: Arrays. Topic: arrays. Difficulty: Easy. Patterns: math.