Longest non-breaking subsequence of vovels
static int longestSubsequence(String s) {
int point=0, len=0, maxlen=0;
char[] c = { 'a', 'e', 'i', 'o', 'u' };
for(int i=0; i < s.length(); i++) {
//System.out.println(point);
if(point == 4) {
if(s.charAt(i) == c[point]) {
len++;
} else {
System.out.println("maxx");
if(len > maxlen) maxlen=len+1;
point = 0;
len = 0;
}
} else if(s.charAt(i) == c[point]) {
len++;
} else if(s.charAt(i) == c[point+1]) {
point++;
len++;
} else {
point = 0;
len = 0;
}
}
if(len > maxlen) maxlen=len;
return maxlen;
}
public static void CountVowelsSubstring(){
Scanner sc = new Scanner(System.in);
ArrayList<String> list = new ArrayList<>();
String s = sc.nextLine();
int len = s.length();
int count=0;
for(int i=0; i<len;i++) {
for(int j=i+1;j<=len;j++) {
String temp = s.substring(i,j);
if(!list.contains(temp)) {
list.add(temp);
for (int k = 0; k < temp.length(); k++) {
char ch = temp.charAt(k);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
count++;
}
}
}
}
}
System.out.println(count);
sc.close();
}
public static void StViva() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int prev =Integer.MAX_VALUE;
ArrayList<Integer> al = new ArrayList<>();
for(int i=0; i<n; i++) {
al.add(sc.nextInt());
}
int c = 0;
while(true) {
boolean flag = true;
for(int i=1; i<al.size(); i++) {
if(al.get(i) > prev ) {
prev = al.get(i);
al.remove(i);
flag = false;
i--;
System.out.println("Delete: "+prev);
} else {
prev = al.get(i);
}
System.out.println(i+"-"+prev);
}
if(flag) {
break;
}else {
c++;
}
}
System.out.println(c);
sc.close();
}