LeetCodeFind the Score of All Prefixes of an ArrayFind the Score of All Prefixes of an ArrayMediumArrayPrefix SumSolution export function findPrefixScore(nums: number[]): number[] { const answer: number[] = []; let sum = 0; let maxValue = 0; for (const num of nums) { maxValue = Math.max(maxValue, num); sum += maxValue + num; answer.push(sum); } return answer; } Complexity Time: O(n)O(n)O(n) Space: O(n)O(n)O(n) LeetCodeFind the Score of All Prefixes of an Arrayhttps://leetcode.com/problems/find-the-score-of-all-prefixes-of-an-array