A river gauge records the water level once a day in levels. Return a list of the same length where position i holds the highest level recorded on or before day i (the high-water mark so far).
Examples
Input: levels = [3, 1, 4, 1, 5, 9, 2]
Output: [3, 3, 4, 4, 5, 9, 9]
Input: levels = [-5, -9, -1]
Output: [-5, -5, -1]
Constraints
0 <= len(levels) <= 10**5-10**6 <= levels[i] <= 10**6- Target: O(n) time.
Goals
- Build an output list of the same length as the input
- Carry a running maximum across iterations