Sum of Each Matrix Row
Given a nonempty rectangular integer matrix, return an array containing the sum of each row in top-to-bottom order. Negative and zero values contribute…
Given a nonempty rectangular integer matrix, return an array containing the sum of each row in top-to-bottom order. Negative and zero values contribute normally.
1 to 1000 rows, 1 to 500 columns, at most 250,000 cells; every row has the same positive length. Every cell is an integer from -1000 through 1000. The visualizer uses matrices of at most 6 rows and 6 columns; larger valid inputs are execution-only.
Example 1: input matrix = [[3, -1, 4], [0, 5, -2]]; output [6, 3]. The first row totals 3 + (-1) + 4 = 6; the second totals 0 + 5 + (-2) = 3.
Example 2: input matrix = [[-7]]; output [-7]. The only row contains -7, so its sole subtotal is -7.
Example 3: input matrix = [[-7, 0, 2]]; output [-5]. The single row totals -7 + 0 + 2 = -5, producing one output element.
Category: Arrays. Topic: arrays. Difficulty: Easy. Patterns: math.