1704. Determine if String Halves Are Alike Easy
1/**
2 * [1704] Determine if String Halves Are Alike
3 *
4 * You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half.
5 * Two strings are alike if they have the same number of vowels ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'). Notice that s contains uppercase and lowercase letters.
6 * Return true if a and b are alike. Otherwise, return false.
7 *
8 * Example 1:
9 *
10 * Input: s = "book"
11 * Output: true
12 * Explanation: a = "b<u>o</u>" and b = "<u>o</u>k". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
13 *
14 * Example 2:
15 *
16 * Input: s = "textbook"
17 * Output: false
18 * Explanation: a = "t<u>e</u>xt" and b = "b<u>oo</u>k". a has 1 vowel whereas b has 2. Therefore, they are not alike.
19 * Notice that the vowel o is counted twice.
20 *
21 *
22 * Constraints:
23 *
24 * 2 <= s.length <= 1000
25 * s.length is even.
26 * s consists of uppercase and lowercase letters.
27 *
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/determine-if-string-halves-are-alike/
32// discuss: https://leetcode.com/problems/determine-if-string-halves-are-alike/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37 pub fn halves_are_alike(s: String) -> bool {
38 false
39 }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_1704() {
50 }
51}
52
Back
© 2025 bowen.ge All Rights Reserved.