String Polynomial Hashing
Given a string S, print the hash code of that string using Polynomial Hashing.Input Format
Note: Use prime number = 31 and print the answer mod 1000000007.
The first line contains an integer T denoting the number of test cases.Output Format
T lines follow each containing a string S.
Print an integer (the hashcode of the string) mod 1000000007 and take prime number 31 for hashing.Question Video
String s consists of only lowercase English alphabetsSample Input
|S| <= 10^5
6Sample Output
ab
abc
abcd
abc
xyz
pqr
63
2946
122110
2946
25785
17841
-
Asked in Companies
-
Related Topics
Video Solution
Code Solution
{ }
{ }
Run