Longest Alternating Vowel-Consonant Substring

Medium
string alternating-pattern vowel-consonant substring
Problem Description

Find the length of the longest substring where vowels and consonants alternate. Vowels are a, e, i, o, u.

Input Format
A single string containing only lowercase letters.
Output Format
Length of the longest alternating vowel-consonant substring.
Constraints
• 1 ≤ string length ≤ 1000
• String contains only lowercase letters
• Vowels: a, e, i, o, u
• Alternating means vowel-consonant-vowel-consonant...
• Single character has length 1
Sample Input/Output
Input:
abecidofu
Output:
9
Explanation

String "abecidofu": a(V)-b(C)-e(V)-c(C)-i(V)-d(C)-o(V)-f(C)-u(V). All 9 characters alternate between vowel and consonant.

Solution Hints
95
Points
2000ms
Time Limit
128MB
Memory Limit
Code Editor
Register to Submit
Register to Access Code Editor

Create a free account to solve coding problems and track your progress.

Register Now
Feedback