1704. Determine if String Halves Are Alike

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1704

class Solution:
    def halvesAreAlike(self, s: str) -> bool:
        vowels = set('aeiouAEIOU')
        a, b = s[: len(s) >> 1], s[len(s) >> 1 :]
        return sum(c in vowels for c in a) == sum(c in vowels for c in b)