Given a table of numbers, write an algorithm to find the highest number in each row of the table.
Create an empty list to store the largest value from each row. Go through each row: For every row in the matrix. Identify the highest value within that row, add this largest number to the list.
matrix = [ [ 1, 4, 7 ], [ 2, 5, 8 ], [ 3, 6, 9 ] ] output = [] for i in range(len(matrix)): output.append(max(matrix[i])) print(output)
const matrix = [ [ 1, 4, 7 ], [ 2, 5, 8 ], [ 3, 6, 9 ] ]; const output = []; for (let i = 0; i < matrix.length; i++) { output.push(Math.max(...matrix[i])); } console.log(output);