Given a string which contains lowercase English alphabets. The task is to replace each consonant with the next immediate consonant that comes in English alphabets.
Let’s say we have to replace character , it will be replaced by . Another example, let’s say we have to replace character , the next immediate consonant is , hence will be replaced by .
Note: If the character is ‘z’, then look circularly in English alphabets for the next consonant, i.e. replace it with ‘b’.
Input : str = "geeksforgeeks" Output : heeltgosheelt Input : str = "gfg" Output : hgh
- Iterate the string elements from left to right.
- It the string element is consonant, then check the next immediate alphabet of this element.
- If the next immediate alphabet is a consonant, then replace it with the this alphabet. If it is a vowel, then replace the string element with 2nd immediate alphabet as there are no consecutive vowels in English alphabets.
Below is the implementation of the above program:
- Replace all consonants with nearest vowels in a string
- Find the number of words of X vowels and Y consonants that can be formed from M vowels and N consonants
- Program to remove consonants from a String
- Modify string by removing vowels in between two consonants
- Check if a string can be converted to another string by replacing vowels and consonants
- Count consonants in a string (Iterative and recursive methods)
- Number of words that can be made using exactly P consonants and Q vowels from the given string
- Modify the string by swapping continuous vowels or consonants
- Encrypt string with product of number of vowels and consonants in substring of size k
- Count strings with consonants and vowels at alternate position
- Arrange consonants and vowels nodes in a linked list
- Arrangement of words without changing the relative position of vowel and consonants
- Substrings starting with vowel and ending with consonants and vice versa
- Replace two substrings (of a string) with each other
- Replace all occurrences of pi with 3.14 in a given string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.