Longest subsequencee variation

Given a string find longest subsequence in a string such that vowels and consonants occur in alternate fashion… If 2 subsequence are of same length then return lexicographically smallest subsequence
Pls give ur approaches
This problem was asked in infytq which was held today
@anon55659401 @loopfree.

Pls reply this post !!

i will try to explain this via an example
take input string as : “ycgeapkabc”

Now you can divide this string into contiguous substrings having same features ( here having same feature implies both being consonants or both being vowels )
the above string can be divided as { “ycg” , “ea” , “pk”, “a” , “bc” }

now all you need to do is pick lexographically smallest character from each substring and combine it to the result { “c”, “a”, “k” , “a”, “b” }

here result being “cakab”