Given two strings S1 and S2, you are allowed only to change a character at any position to any vowel if it is a vowel or to a consonant, if it is a consonant. The task is to check if a string S1 can be changed to S2 or S2 can be changed to S1.
Input: S1 = “abcgle”, S2 = “ezggli”
Change ‘a’ to ‘e’, ‘b’ to ‘z’, ‘c’ to ‘g’ and ‘e’ to ‘i’.
Input: S1 = “abc”, S2 = “cgth”
Approach: The following conditions should be followed to solve the above problem:
- The length of both the string should be equal.
- At every index, the character of S1 and S2 should be both vowel or consonant.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if one string can be converted to another
- Check if a string can be converted to another by swapping of adjacent characters of given type
- Check if a given string can be converted to another by given possible swaps
- Replace consonants with next immediate consonants alphabetically in a String
- Find the player to last modify a string such that even number of consonants and no vowels are left in the string
- Check whether all the substrings have number of vowels atleast as that of consonants
- Encrypt string with product of number of vowels and consonants in substring of size k
- Modify string by removing vowels in between two consonants
- Replace all consonants with nearest vowels in a string
- Modify the string by swapping continuous vowels or consonants
- Minimum swaps required to move all vowels occurs after consonants in a given string
- Count strings with consonants and vowels at alternate position
- Longest subsequence consisting of alternate vowels and consonants
- Longest Substring having equal count of Vowels and Consonants
- Check if a String can be converted to Pangram in K changes
- Check if one string can be converted to other using given operation
- Check whether str1 can be converted to str2 with the given operations
- Check if a substring can be Palindromic by replacing K characters for Q queries
- Check if a string can be obtained by rotating another string 2 places
- Check if a string can be formed from another string using given constraints
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.