text: Maximum occurrence of prefix in the Array | CPP program to find the number of occurrences of prefix which occurs maximum no . of time ; Function to return the count of the required prefix ; Find the frequency of first character of string ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int prefixOccurrences ( string str ) { char c = str [ 0 ] ; int countc = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == c ) countc ++ ; } return countc ; } int main ( ) { string str = " abbcdabbcd " ; cout << prefixOccurrences ( str ) ; return 0 ; }