Running Maximum
EasyArrayPrefix Sum
Description
Given an array of integers nums, return an array where each position holds the maximum of all values up to and including that position.
Examples
Input:
nums = [1,3,2,5,4]Output:
[1,3,3,5,5]Explanation:
Each position keeps the highest value seen so far, producing [1,3,3,5,5].
Input:
nums = [-1,-2,-3]Output:
[-1,-1,-1]Explanation:
Each position keeps the highest value seen so far, producing [-1,-1,-1].
Input:
nums = [7]Output:
[7]Explanation:
Each position keeps the highest value seen so far, producing [7].
Constraints
- •
1 ≤ nums.length ≤ 10⁴ - •
-10⁹ ≤ nums[i] ≤ 10⁹