Function to generate the sum of indices
static void sumOfIndices ( String s ) { int N = s . length ( ) ; int x = ( int ) ( Math . ceil ( Math . log ( N ) / Math . log ( 2 ) ) ) ; int seg_size = 2 * ( int ) Math . pow ( 2 , x ) - 1 ; int segment [ ] = new int [ seg_size ] ; int count = 0 ;