LeetCode 1539. Kth Missing Positive Number in F#
URL
https://leetcode.com/problems/kth-missing-positive-number/description/
Code
https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/problems/1539/main.fsx
let findKthPositive (arr: int list) (k: int) =
let rec findKthPositive' i missing s k =
if Set.contains i s then
findKthPositive' (i + 1) missing s k
else
let missing' = missing + 1
if missing' = k then
i
else
findKthPositive' (i + 1) missing' s k
let s = Set.ofList arr
findKthPositive' 1 0 s k