URL
https://leetcode.com/problems/largest-3-same-digit-number-in-string/description/?envType=daily-question&envId=2023-12-04
Code
https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/challenge/202312/largest_3_same_digit_number_in_string/main.fsx
open System
let largestGoodInteger (num: string) : string =
let rec largestGoodInteger' (cs: char list) acc =
match cs with
| [] -> acc
| a :: b :: c :: t when a = b && b = c ->
let s = [ a; a; a ] |> String.Concat
if s > acc then
largestGoodInteger' t s
else
largestGoodInteger' t acc
| _ :: t -> largestGoodInteger' t acc
largestGoodInteger' (Seq.toList num) ""