Question: Julia has a string, s, consisting of one or more of the following letters: a, e, i, o, and u We define a magical subsequence


Julia has a string, s, consisting of one or more of the following letters: a, e, i, o, and u We define a magical subsequence of s to be a sequence of letters derived from s that contains all five vowels in order This means a magical subsequence will have one or more a's followed by one or more e's followed by one or more i's fol- lowed by one or more o's followed by one or more u's. For ex ample, if s "aeeiooua", then "aeiou" and "aeeioou" are magi cal subsequences but "aeio" and "aeeioua" are not. Complete the longestSubsequence function in your editor. It has 1 parameter: a string, s. It must return an integer denoting the length of the longest magical subsequence in s. If no mag ical subsequence can be constructed, return 0 Output Format Your function must return an integer denoting the length of the longest magical subsequence in s (if no such subsequence exists, this value is 0) This is printed to stdout by the locked stub code in your editor aeiaaioooaauuaeiou Sample Output 10 In the table below, the component characters of the longest magical sub- sequence are red: Input Format The locked stub code in your editor reads a single string, s, from stdin and passes it to your function Constraints 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
