Best in each row
Inputs
cells is a grid: a list of 1 to 5 rows, each with the same number (1 to 5) of whole numbers from -9 to 9.
Your tasks
- Create an empty list
maxima. - Use a loop over the rows. For each row, find its largest number with an inner loop and add it to
maxima. - Complete
rowMaximaso it returnsmaxima. Return it, do not print it.
Example
With cells = [[1, 9, 3], [4, 5, 6]], rowMaxima returns [9, 6].
Rules
- One number per row, in row order.
Test data
TEST DATA 1: cells is [[1, 9, 3], [4, 5, 6]]
TEST DATA 2: cells is [[-4]]
Practice focus
Two-dimensional data is a loop over rows with a loop over columns inside. Grids lead straight to flood fill, islands, dynamic programming tables and path problems.