cft
Become a CreatorSign inGet Started

LeetCode 78. Subsets in F#

LeetCode Daily Program at 2022/02/13


user

Shohei Yoshida

3 months ago | 1 min read
Follow

leetcode-78-subsets-f-oeddx

URL

https://leetcode.com/problems/subsets/

Code

https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/problems/0078/main.fsx

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

Upvote


user
Created by

Shohei Yoshida

Follow

A programmer of DeNA

A Programmer


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles