Problem statement
Given an array of integers, produce a row where position i holds the largest value from index i to the last index.
It is the prefix question read backwards, and the loop starts at the end.
Examples
Inputa = [3, 1, 4, 1, 5, 9, 2]
Outputsuf = [9, 9, 9, 9, 9, 9, 2]
The 9 at index 5 is the tallest wall from every earlier position onward.
Inputa = [1, 3, 5, 7, 9]
Outputsuf = [9, 9, 9, 9, 9]
On a rising array every suffix is capped by the last cell.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing