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:
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.
- 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
- Seating arrangement of N boys sitting around a round table such that two particular boys sit together
- Find the number of words of X vowels and Y consonants that can be formed from M vowels and N consonants
- Primality test for the sum of digits at odd places of a number
- Check whether sum of digits at odd places of a number is divisible by K
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Check if product of digits of a number at even and odd places is equal
- Find the sum of digits of a number at even and odd places
- Count of numbers in range which are divisible by M and have digit D at odd places
- Total number of ways to place X and Y at n places such that no two X are together
- Longest Common Prefix using Word by Word Matching
- C program to Replace a word in a text by another given word
- C program to find and replace a word in a File by another given word
- Find the word from a given sentence having given word as prefix
- 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
- Arrangement of words without changing the relative position of vowel and consonants
- 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.
Improved By : Mithun Kumar