call(back)
Algorithms & Data StructureseasySign in to star problems

Elementwise Matrix Sum

Return the elementwise sum of two matrices of the same shape, given as arrays of rows.

addMatrices([[1, 2], [3, 4]], [[5, 6], [7, 8]])  ->  [[6, 8], [10, 12]]
addMatrices([], [])                              ->  []

This is the first of three warm-ups in a data-science screen; the others count name frequencies and find the longest run of consecutive integers.

Hints

Hint 1

Two nested maps; the empty matrix falls out of them.

Topics

Asked at

Similar Problems6