LeetCode 78. Subsets in F#
URL
Code
github.com/syohex/dotnet-study/blob/master/..
let rec subsets (nums: int list) : int list list =
match nums with
| [] -> [ [] ]
| head :: tail ->
let rest = subsets tail
let prepends = rest |> List.map (fun s -> [ head ] @ s)
prepends @ rest