Given a string ‘S’ containing vowels and consonants of lowercase English alphabets. The task is to find the number of ways in which the characters of the word can be arranged such that the vowels occupy only the odd positions.
First find the total no. of odd places and even places in the given word.
Total number of even places = floor(word length/2)
Total number of odd places = word length – total even places
Let’s consider the string “contribute” then there are 10 letters in the given word and there are 5 odd places, 5 even places, 4 vowels and 6 consonants.
Let us mark these positions as under:
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
Now, 4 vowels can be placed at any of the five places, marked 1, 3, 5, 7, 9.
The number of ways of arranging the vowels = 5_P_4 = 5! = 120
Also, the 6 consonants can be arranged at the remaining 6 positions.
Number of ways of these arrangements = 6_P_6 = 6! = 720.
Total number of ways = (120 x 720) = 86400
Below is the implementation of the above approach:
- Number of ways to arrange a word such that all vowels occur together
- Number of ways to arrange a word such that no vowels occur together
- Program to count vowels, consonant, digits and special characters in string.
- Next word that does not contain a palindrome and has characters from first k
- Possibility of a word from a given set of characters
- Print list items containing all characters of a given word
- Java program to count the characters in each word in a given sentence
- Find largest word in dictionary by deleting some characters of given string
- Find the count of sub-strings whose characters can be rearranged to form the given word
- Find the number of words of X vowels and Y consonants that can be formed from M vowels and N consonants
- Longest Common Prefix using Word by Word Matching
- C program to Replace a word in a text by another given word
- Find the arrangement of queue at given time
- Maximum height of triangular arrangement of array values
- Seating arrangement of n boys and girls alternatively around a round table
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.
Improved By : Mithun Kumar