Skip to main content

LeetCode 2221. Find Triangular Sum of an Array in F#

Published 1 min readMarkdown

URL

Find Triangular Sum of an Array - LeetCode

Code

dotnet-study/fsharp/leetcode/challenge/202509/find_triangular_sum_of_an_array/main.fsx at master · syohex/dotnet-study

let triangleSum (nums: int list) : int =
    let rec triangleSum' nums =
        match nums with
        | [] -> failwith "never reach here"
        | h :: [] -> h
        | _ ->
            let nums = nums |> List.windowed 2 |> List.map (fun v -> (List.sum v) % 10)
            triangleSum' nums

    triangleSum' nums

No comments yet. Be the first to comment.

More from this blog