0 out of 464 challenges solved
Write a Python function `count_vowel_neighbors(s: str) -> int` that takes a string `s` as input and returns the count of characters in the string that have vowels as their neighbors. A vowel is defined as one of the characters `a`, `e`, `i`, `o`, `u` (case-insensitive). #### Rules: 1. Only consider lowercase and uppercase English alphabets. 2. Characters at the beginning or end of the string are considered to have a neighbor only on one side. #### Example Usage: ```python [main.nopy] count_vowel_neighbors("bestinstareels") # Output: 7 count_vowel_neighbors("amazonprime") # Output: 5 count_vowel_neighbors("partofthejourneyistheend") # Output: 12 ```
def count_vowel_neighbors(s: str) -> int: """ Count characters in the string that have vowels as their neighbors. Args: s (str): The input string. Returns: int: The count of characters with vowels as neighbors. """ # Define the set of vowels vowels = {'a', 'e', 'i', 'o', 'u'} count = 0 # Iterate through the string to check neighbors for i in range(len(s)): # Placeholder for logic to check neighbors pass return count