Test Question
You are developing a low-level communication protocol for a satellite array. To prevent signal interference, every data packet—represented as a string of lowercase English letters—must be Stable.
A packet is considered Stable if every vowel in the string is immediately followed by a consonant.
Grounding Rule: If a vowel is the last character in the string, the packet is automatically considered Unstable because it lacks a trailing consonant to "ground" the signal.
Vowels are defined as: {'a', 'e', 'i', 'o', 'u'}. All other lowercase English letters are considered consonants.
Example 1
"orbit"True'o' is followed by 'r', and 'i' is followed by 't'. Both vowels are grounded.
Example 2
"data"FalseThe last character 'a' is a vowel and has no following consonant to ground it.
- ›1 <= packet.length <= 10^5
- ›packet consists of lowercase English letters.
- ›Time Complexity: O(N)
- ›Space Complexity: O(1)
Reference solution available after you attempt the question.
Ready to solve it?
Start a session on Mockbit #1. You'll get graded with specific critique when you submit.