Amazon Online Assessment (OA) - Longest String Made Up Of Only Vowels

Given a string of lowercase characters, remove at most two substrings of any length from the given string so that the remaining string contains only vowels ('a', 'e', 'i', 'o', 'u').

Your aim is to maximize the length of the remaining string. Output the length of the remaining string after the removal of at most two substrings.

NOTE: The answer might be 0, that is, removing the entire string.

Examples

Example 1:

Input: earthproblem
Output: 2

Example 2:

Input: letsgosomewhere
Output: 3

Try it yourself

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro
Favorite (idle)