LeetCode 1704. Determine if String Halves Are Alike
URL
https://leetcode.com/problems/determine-if-string-halves-are-alike/
Code
https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/problems/1704/main.fsx
let halvesAreAlike (s: string) : bool =
let isVowel c =
let c' = System.Char.ToLower(c)
c' = 'a'
|| c' = 'e'
|| c' = 'i'
|| c' = 'o'
|| c' = 'u'
let countVowel cs =
let rec countVowel' cs acc =
match cs with
| [] -> acc
| h :: t -> countVowel' t (acc + if isVowel h then 1 else 0)
countVowel' cs 0
let half = s.Length / 2
let cs = s |> Seq.toList
let front = cs |> List.take half
let last = cs |> List.skip half
(countVowel front) = (countVowel last)