Iterate over the String and store the frequency of all charactrs A vector to store the frequency
int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < N ; i ++ ) { freq [ S . charAt ( i ) - ' a ' ] ++ ; }