Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 930 Bytes

File metadata and controls

21 lines (14 loc) · 930 Bytes

Interview 1

Ask the candidate to write a function to add up the sum of each row in a matrix of arbitrary size, and return an array with the appropriate values. The matrix will always be full of integers. Negative values are possible. All nulls will be counted as zeros.

Whiteboard Process

Code Challenge 4.png

Approach & Efficiency

The big O for space is the length of the array. The big 0 for time is the n^2, where n is the length of the array times the length of each array inside the array of arrays.

Solution

Input is an array of arrays (a matrix). Create a new array for the output of the sum of each inner array. Then, loop through the outer array and then use sum to add up all the values of each inner array.