LeetCode 1557. Minimum Number of Vertices to Reach All Nodes in F#
URL
Minimum Number of Vertices to Reach All Nodes - LeetCode
Code
https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/problems/1557/main.fsx
let findSmallestSetOfVertices (n: int) (edges: (int * int) list) : int list =
let reachables = edges |> List.map snd |> Set.ofList
seq { 0 .. (n - 1) }
|> Seq.filter (fun i -> Set.contains i reachables |> not)
|> List.ofSeq