Shohei Yoshida
Shohei Yoshida's Blog

Shohei Yoshida's Blog

LeetCode 151. Reverse Words in a String in F#

Shohei Yoshida's photo
Shohei Yoshida
·Nov 13, 2022·

1 min read

URL

leetcode.com/problems/reverse-words-in-a-st..

Code

github.com/syohex/dotnet-study/blob/master/..

let reverseWords (s: string) : string =
    s.Split [| ' ' |]
    |> Seq.filter (System.String.IsNullOrEmpty >> not)
    |> Seq.rev
    |> Seq.toArray
    |> String.concat " "
 
Share this