452. Minimum Number of Arrows to Burst Balloons in F#
URL
Minimum Number of Arrows to Burst Balloons - LeetCode
Code
https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/problems/0452/main.fsx
let findMinArrowShots (points: (int * int) list) : int =
let rec findMinArrowShots' points (end1: int) acc =
match points with
| [] -> acc
| (s, e) :: t ->
if s <= end1 then
findMinArrowShots' t (System.Math.Min(e, end1)) acc
else
findMinArrowShots' t e (acc + 1)
let points = points |> List.sortWith (fun (s1, _) (s2, _) -> compare s1 s2)
findMinArrowShots' (points.Tail) (snd points.Head) 1