---
# System prepended metadata

title: 2640. Find the Score of All Prefixes of an Array
tags: [Leetcode, Prefix Sum, Medium]

---

# 2640. Find the Score of All Prefixes of an Array
###### tags: `Leetcode` `Medium` `Prefix Sum`
Link: https://leetcode.com/problems/find-the-score-of-all-prefixes-of-an-array/description/
## Code
```python=
class Solution:
    def findPrefixScore(self, nums: List[int]) -> List[int]:
        ans = [0]
        maxVal = 0
        for i, num in enumerate(nums):
            maxVal = max(maxVal, num)
            ans.append(ans[-1]+maxVal+num)
        return ans[1:]
```