Given a string str and two integers P and Q. The task is to find the total count of words that can be formed by choosing exactly P consonants and Q vowels from the given string.
Input: str = “geek”, P = 1, Q = 1
“ge”, “ge”, “eg”, “ek”, “eg”, “ek”,
“ke” and “ke” are the possible words.
Input: str = “crackathon”, P = 4, Q = 3
Approach: Since P consonants and Q vowels has to be chosen from the original count of consonants and vowels in the given string. So, binomial coefficient can be used to calculate the combinations of choosing these characters and the characters chosen can be arranged in themselves using the factorial of their count.
Below is the implementation of the above approach:
- Find the number of words of X vowels and Y consonants that can be formed from M vowels and N consonants
- Encrypt string with product of number of vowels and consonants in substring of size k
- Replace all consonants with nearest vowels in a string
- Modify string by removing vowels in between two consonants
- Modify the string by swapping continuous vowels or consonants
- Check whether all the substrings have number of vowels atleast as that of consonants
- Count strings with consonants and vowels at alternate position
- Arrange consonants and vowels nodes in a linked list
- Replace consonants with next immediate consonants alphabetically in a String
- Arrangement of words without changing the relative position of vowel and consonants
- Count the number of vowels occurring in all the substrings of given string
- Program to remove consonants from a String
- Count consonants in a string (Iterative and recursive methods)
- First X vowels from a string
- Modify the string such that it contains all vowels at least once
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.