Function to count frequency of each char in the string . freq [ 0 ] for ' a ' , ... . , freq [ 25 ] for ' z '
void countFreq ( string str , int freq [ ] , int len ) { for ( int i = 0 ; i < len ; i ++ ) freq [ str . at ( i ) - ' a ' ] ++ ; }