Given a string str of even size N consisting of lowercase English alphabets. The task is to find the number of rotated strings of str which have more vowels in the first half than the second half.
Input: str = “abcd”
All rotated string are “abcd”, “dabc”, “cdab”, “bcda”.
The first two rotated strings have more vowels in
the first half than the second half.
Input: str = “abecidft”
Approach: An efficient approach is to make string s = str + str then the size of the s will be 2 * N. Now, make a prefix array to store the number of vowels present from the 0th index to the ith index. Then run a loop from N – 1 to 2 * N – 2 to get all the rotated strings of str. Find the count of required rotated strings.
Below is the implementation of the above approach:
- Count binary strings with twice zeros in first half
- Sum of elements in range L-R where first half and second half is filled with odd and even numbers
- Find prime numbers in the first half and second half of an array
- Find the sum of the first half and second half elements of an array
- Count the number of vowels occurring in all the substrings of given string
- Python program to count number of vowels using sets in given string
- Count strings with consonants and vowels at alternate position
- Longest Even Length Substring such that Sum of First and Second Half is same
- Reduce every element of the array to it's half retaining the sum zero
- Check if at least half array is reducible to zero by performing some operations
- Check if the frequency of any character is more than half the length of the string
- Count the number of common divisors of the given strings
- Count number of binary strings of length N having only 0's and 1's
- Count number of strings (made of R, G and B) using given combination
- Find all even length binary sequences with same sum of first and second half bits | Iterative
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.