long long compute_hash(string const& s) {
const int p = 31;
const int m = 1e9 + 9;
long long hash_value = 0;
long long p_pow = 1;
for (char c : s) {
hash_value = (hash_value + (c - βaβ + 1) * p_pow) % m;
p_pow = (p_pow * p) % m;
}
return hash_value;
}
This is the code for the string hashing ,What is the significance of this expression β(c - βaβ + 1) 'β??
Doubt on the code of string hashing
hello @Somasree
it converts character to int .
for example
if character c is βaβ then it will give 1
if character c is βbβ then it will give 2
if character c is βcβ then it will give 3
if character c is βdβ then it will give 4
so onβ¦
ok thank u so much 
I hope Iβve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
yeah . . β¦
if we have n vertices, then we can pick two vertices and draw an edge between then. that why nC2 = n *(n-1)/2
ok understood thank u 
