I was going through the editorial
When they try to calculate hash for a specefic segment in a string using the following logic
Hash(S[l..r]) = (Hash(S[0..r]) - Hash(S[0..l-1]) * MAGIC^(r-l+1)) % MOD How this relation is working ?? what is the logic behind multiplication with MAGIC^(r-l+1) ?? As i observed , the logic should be , Hash(S[l..r]) = (Hash(S[0..r]) - (Hash(S[0..l-1]* MAGIC^(r-l+1)))%MOD +MOD) % MOD
Can someone plz explain the same ??