LeetCode 1512. Number of Good Pairs in F#
URL
Number of Good Pairs - LeetCode
Code
https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/problems/1512/main.fsx
let numIdenticalPairs (nums: int list) : int =
let rec numIdenticalPairs' nums acc =
match nums with
| [] -> acc
| h :: t ->
let matched = List.filter ((=) h) t |> List.length
numIdenticalPairs' t (matched + acc)
numIdenticalPairs' nums 0