Given a string, print and count all prefixes in which first alphabet has greater frequency than second alphabet.
Take two alphabets from the user and compare them. The prefixes in which the alphabet given first has greater frequency than the second alphabet, such prefixes are printed, else the result will be 0.
Input : string1 = "geek", alphabet1 = "e", alphabet2 = "k" Output : ge gee geek 3 Input : string1 = "geek", alphabet1 = "k", alphabet2 = "e" Output : 0
Approach : Take an empty string to store the string values of all the prefixes formed. Then check for the alphabet with greater frequency than the second alphabet. If no such case is found then the result will be 0 prefixes.
Below is the implementation :
gee geek geeks geeksf geeksfo geeksfor geeksforge geeksforgee geeksforgeek geeksforgeeks 10
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Index of character depending on frequency count in string
- Python - Bigrams Frequency in String
- Python | Frequency of numbers in String
- Python | Frequency of each character in String
- Python | Frequency of substring in given string
- Python - Elements frequency count in multiple lists
- Find frequency of each word in a string in Python
- Python - Words Frequency in String Shorthands
- Python - Prefix frequency in string List
- Python | Maximum frequency character in String
- Python | Construct string from character frequency tuple
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Python String | count()
- Frequency of a substring in a string
- Python | Count and display vowels in a string
- Python | Count occurrences of a character in string
- Python | Count overlapping substring in a given string
- Remove even frequency characters from the string
- Calculate the frequency of each word in the given string
- Frequency of a string in an array of strings
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.