LeetCode 58. Length of Last Word in F#

URL

https://leetcode.com/problems/length-of-last-word/description/

Code

https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/challenge/202404/length_of_last_word/main.fsx

let lengthOfLastWord (s: string) : int =
    s.TrimEnd()
    |> Seq.rev
    |> Seq.tryFindIndex ((=) ' ')
    |> Option.defaultValue s.Length