#1704
Determine if String Halves Are Alike
newbie · 190 · lc easy +16 · verified · 78.8% accepted · 2,332 likes · top 90%
Description
You are given a string s of even length. Divide it into two equal halves a and b. Two strings are alike if they contain the same total number of vowels ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'). Return true if a and b are alike, otherwise return false.
Example 1:
Input: s = "book"
Output: true
Explanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
Example 2:
Input: s = "textbook"
Output: false
Explanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
Notice that the vowel o is counted twice.
Code
1
2
3