Dsa
Strings
Medium
Rhythmic Substring Flip
Define 'V' as vowels (aeiou) and 'C' as consonants. A string is 'rhythmic' if its character types alternate (e.g., VCVCV or CVCVC). Find the length of the longest substring that can be transformed into a rhythmic string by changing the 'type' of at most ONE character.
Example:
Input: 'abaac'
Types: VCVVV
Changing index 3 to 'C' results in VCVVC (not rhythmic) or changing index 3 to 'C' in substring 'abaac' makes it 'VCVCV'.
Output: 5
Key concepts
sliding windowparitystrings
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now