Category: vowel-consonant

Length of the longest substring consisting only of vowels in non-increasing order

import java.io.*;import java.util.*;  class GFG {                  static int count(String S, int N)    {                  char ch[] = { ‘u’, ‘o’, ‘i’, ‘e’, ‘a’ };                  int j = 0;                  int res = 0;                          int count = 0;                  HashSet mp = new HashSet();                  for (int i = 0; i < N; ++i) {                          if (S.charAt(i) == ch[j]) {                                  ++count;                                  mp.add(S.charAt(i));                                  if (mp.size() == 5) {                    res = Math.max(res, count);                }            }                                      else if (j + […]

Continue Reading

Sort a string without altering the position of vowels

Sort a string without altering the position of vowels Given a string S of size N, the task is to sort the string without changing the position of vowels. Examples: Input: S = “geeksforgeeks”Output: feeggkokreessExplanation:The consonants present in the string are gksfrgks. Sorting the consonants modifies their sequence to fggkkrss.Now, update the string by placing […]

Continue Reading

Check if a string can be split into two substrings with equal number of vowels

   import java.io.*;    class GFG {                  public static boolean isVowel(char ch)     {                  if (ch == ‘a’ || ch == ‘e’ || ch == ‘i’             || ch == ‘o’ || ch == ‘u’)             return true;                     if (ch == ‘A’ || ch == ‘E’ || ch == ‘I’             || ch […]

Continue Reading