A Function to calculate the suffix hash Suffix hash is nothing but the prefix hash of the reversed string
void computeSuffixHash ( string str , int n , unsigned long long int suffix [ ] , unsigned long long int power [ ] ) { suffix [ 0 ] = 0 ; suffix [ 1 ] = str [ n - 1 ] ; for ( int i = n - 2 , j = 2 ; i >= 0 && j <= n ; i -- , j ++ ) suffix [ j ] = ( suffix [ j - 1 ] % MOD + ( str [ i ] % MOD * power [ j - 1 ] % MOD ) % MOD ) % MOD ; return ; }