Shohei Yoshida
Shohei Yoshida's Blog

Follow

Shohei Yoshida's Blog

Follow

LeetCode 520. Detect Capital in F#

Shohei Yoshida's photo
Shohei Yoshida
·Jan 2, 2023·

1 min read

URL

https://leetcode.com/problems/detect-capital/description/

Code

https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/challenge/202301/detect_capital/main.fsx

open System

let detectCapitalUse (word: string) : bool =
    let cs = word |> Seq.toList

    if (cs |> List.head |> Char.IsLower) then
        cs |> List.forall Char.IsLower
    else
        cs |> List.forall Char.IsUpper
        || cs |> List.skip 1 |> List.forall Char.IsLower
 
Share this