Expedia | OA| March 2021
Anonymous User
3337

Longest Ordered Subsequence of Vowels

Given a string consisting of only vowels, find the length of longest subsequence in the given string such that it consists of all five vowels and is a sequence of one or more a’s, followed by one or more e’s, followed by one or more i’s, followed by one or more o’s and followed by one or more u’s.

Input : str = "aeiaaioooaauuaeiou"
Output : 10
{a, a, a, a, a, a, e, i, o, u}

Got this question in my Expedia OA today, I was able to solve this question with 5/15 test cases passing.
I was getting TLE for others.

I tried using memoization using a Dictionary with key as lastCharacter, subSequenceLength, curIndex, but i was still getting TLE.

I was able to solve the other 2 Easy/ Medium questions. Not sure if I will clear this round. Any help would be appreciated.

Update: I got a call from recruiter that I cleared the round. :)

Comments (5)