Skip to content

Practice Find the Score of All Prefixes of an Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2640
LeetCode Problem

Find the Score of All Prefixes of an Array

Problem Statement

For each nums index j, define its converted value as nums[j] plus the largest value in nums[0..j]. Return an array whose entry i is the sum of converted values from index 0 through i, which is the score of that prefix.

Source: Find the Score of All Prefixes of an Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [2,3,7,5,10]
Output
[4,10,24,36,56]

# Example 2

Input
nums = [1,1,2,4,8,16]
Output
[2,4,8,16,32,64]

Constraints

1 <= nums.length <= 10^5
1 <= nums[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Find the Score of All Prefixes of an Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.