Best so far
Inputs
values is a list of 0 to 14 whole numbers, each from -30 to 30.
Your tasks
- Create an empty list
maxes. - Use a loop over
values. After looking at each number, add the largest number seen so far (including this one) tomaxes. - Complete
runningMaxso it returnsmaxes. Return it, do not print it.
Example
With values = [3, 1, 4, 1, 5, 2], runningMax returns [3, 3, 4, 4, 5, 5].
Rules
maxesis as long asvalues.
Test data
TEST DATA 1: values is [3, 1, 4, 1, 5, 2]
TEST DATA 2: values is []
Practice focus
Put an if inside the loop to keep, skip or change items. Filtering, mapping and comparing neighbours show up in nearly every array question.