# 12.01.2024 [1704. Determine if String Halves Are Alike]
Are aeiouAEIOU count the same in the two halves of string.
12.01.2024
1704. Determine if String Halves Are Alike easy
blog post
Join me on Telegram
https://t.me/leetcode_daily_unstoppable/469
Problem TLDR
Are aeiouAEIOU count the same in the two halves of string.
Approach
Let’s use some Kotlin’s API:
toSet
take
drop
count
Complexity
Time complexity:
O(n)Space complexity:
O(n), can be O(1) withasSequence
Code
val vw = "aeiouAEIOU".toSet()
fun halvesAreAlike(s: String) =
s.take(s.length / 2).count { it in vw } ==
s.drop(s.length / 2).count { it in vw }