LeetCode 3075. Maximize Happiness of Selected Children in F#
URL
Maximize Happiness of Selected Children - LeetCode
Code
let maximumHappinessSum (happiness: int list) (k: int) : int64 =
happiness
|> List.sort
|> List.rev
|> List.indexed
|> List.take k
|> List.fold (fun acc (i, v) -> acc + int64 (max (v - i) 0)) 0L
Comments
Join the discussionNo comments yet. Be the first to comment.