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
- Program to remove consonants from a String
- Check if a string can be converted to another string by replacing vowels and consonants
- Modify string by removing vowels in between two consonants
- Modify the string by swapping continuous vowels or consonants
- Count consonants in a string (Iterative and recursive methods)
- Encrypt string with product of number of vowels and consonants in substring of size k
- Arrange consonants and vowels nodes in a linked list
- Count strings with consonants and vowels at alternate position
- Substrings starting with vowel and ending with consonants and vice versa
- Arrangement of words without changing the relative position of vowel and consonants
- Replace two substrings (of a string) with each other
- Replace all occurrences of pi with 3.14 in a given string
- Replace a character c1 with c2 and c2 with c1 in a string S
- Replace all occurrences of a string with space
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.