LeetCode 2640. Find the Score of All Prefixes of an Array in F#
URL
Find the Score of All Prefixes of an Array - LeetCode
Code
https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/problems/2640/main.fsx
let findPrefixScore (nums: int list) : int64 list =
let rec findPrefixScore' (nums: int64 list) max sum acc =
match nums with
| [] -> List.rev acc
| h :: t ->
let max' = System.Math.Max(h, max)
let sum' = sum + max' + h
findPrefixScore' t max' sum' (sum' :: acc)
let nums' = nums |> List.map int64
findPrefixScore' nums' 0 0 []