LeetCode 1475. Final Prices With a Special Discount in a Shop in F#
URL
Code
let finalPrices (prices: int list) : int list =
let rec finalPrices' prices acc =
match prices with
| [] -> List.rev acc
| h :: t ->
match List.tryFind ((>=) h) t with
| Some(v) -> finalPrices' t ((h - v) :: acc)
| None -> finalPrices' t (h :: acc)
finalPrices' prices []