This is a verified interview question from Schlumbergera. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Count Vowels Having Consonant Neighbours - Schlumbergera Online Assessment IIT BHU" covers key patterns like Arrays.
"Given a string `s`, count the number of vowels such that **both its immediate neighbours are consonants**. A vowel is: ```text a, e, i, o, u ``` For a vowel at index `i`, it should satisfy: ```text s[i-1] → consonant s[i] → vowel s[i+1] → consonant ``` The first and last characters cannot be counted because they do not have two neighbours. ### Example 1 ```text Input: s = "abcde" ``` The vowel `e` is at the last position, so it has no right neighbour. The vowel `a` is at the first position, so it has no left neighbour. ```text Output: 0 ``` ### Example 2 ```text Input: s = "bat" ``` `a` has: ```text left = b → consonant right = t → consonant ``` Therefore: ```text Output: 1 ``` ### Example 3 ```text Input: s = "banana" ``` For every `a`: ```text b a n → valid n a n → valid n a → no right neighbour ``` Therefore: ```text Output: 2 ``` ### Constraints ```text 1 ≤ |s| ≤ 10^5 ``` **Note:** Assume the string contains English alphabetic characters. Case-insensitive vowel checking may be used if uppercase letters are allowed."
Join thousands of developers practicing for Schlumbergera.