Consider following letters : a, e, i, o, u
print Magical subsequence of the string that contains all five vowels in order.
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class OnMobile {
- public static int i=1;
- static char getNext(){
- i=i+1;
- String s2="aeiou";
- if(i>s2.length()){
- i=i-2;
- }
- else if(i==s2.length()){
- i=i-1;
- }
- return s2.charAt(i);
- }
- static int longestSubsequence(String s) {
- Pattern pattern = Pattern.compile(".a.e.i.o.u.");
- Matcher matcher = pattern.matcher(s);
- boolean matchFound = matcher.matches();
- if(!matchFound){
- return 0;
- }
- int count=0;