2640. Find the Score of All Prefixes of an Array
We define the conversion array
conver
of an arrayarr
as follows:
conver[i] = arr[i] + max(arr[0..i])
wheremax(arr[0..i])
is the maximum value ofarr[j]
over0 <= j <= i
.We also define the score of an array
arr
as the sum of the values of the conversion array ofarr
.Given a 0-indexed integer array
nums
of lengthn
, return an arrayans
of lengthn
whereans[i]
is the score of the prefixnums[0..i]
.
1 | class Solution { |