LeetCode 2405. Optimal Partition of String in F#
URL
Optimal Partition of String - LeetCode
Code
https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/problems/2405/main.fsx
let partitonString (s: string) : int =
let rec partitonString' cs window acc =
match cs with
| [] -> acc
| h :: t ->
if Set.contains h window then
partitonString' t (Set.add h Set.empty) (acc + 1)
else
partitonString' t (Set.add h window) acc
partitonString' (Seq.toList s) Set.empty 1