LeetCode 1833. Maximum Ice Cream Bars in F#
URL
Maximum Ice Cream Bars - LeetCode
Code
dotnet-study/main.fsx at master · syohex/dotnet-study · GitHub
let maxIceCream (costs: int list) (coins: int) : int =
let rec maxIceCream' i sum costs coins =
match costs with
| [] -> i
| h :: t ->
let sum' = sum + h
if sum' > coins then
i
else
maxIceCream' (i + 1) sum' t coins
maxIceCream' 0 0 (costs |> List.sort) coins