LeetCode 2490. Circular Sentence in F#
URL
https://leetcode.com/problems/circular-sentence/description/?envType=daily-question&envId=2024-11-02
Code
https://leetcode.com/problems/circular-sentence/description/?envType=daily-question&envId=2024-11-02
let isCircularSentence (sentence: string) : bool =
let words = sentence.Split(' ') |> Array.toList
words
|> List.fold
(fun (acc, (prev: string)) word ->
if acc then
word.[0] = prev.[prev.Length - 1], word
else
false, word)
(true, List.last words)
|> fst