URL
https://leetcode.com/problems/divide-intervals-into-minimum-number-of-groups/description/?envType=daily-question&envId=2024-10-12
Code
https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/challenge/202410/divide_intervals_into_minimum_number_of_groups/main.fsx
let minGroups (intervals: (int * int) list) : int =
intervals
|> List.fold (fun acc (s, e) -> (e + 1, -1) :: (s, 1) :: acc) []
|> List.sort
|> List.fold
(fun (ret, duplicates) (_, n) ->
let duplicates' = duplicates + n
max ret duplicates', duplicates')
(0, 0)
|> fst