LeetCode 1544. Make The String Great in F#
URL
https://leetcode.com/problems/make-the-string-great/description/
Code
open System
let makeGood (s: string) : string =
let rec makeGood' (cs: char list) (acc: char list) =
match cs with
| [] -> acc |> List.rev |> String.Concat
| h :: t ->
match acc with
| [] -> makeGood' t (h :: acc)
| h' :: t' ->
if h = h' then makeGood' t (h :: acc)
elif Char.ToLower(h) = Char.ToLower(h') then makeGood' t t'
else makeGood' t (h :: acc)
makeGood' (Seq.toList s) []