diff --git a/Rolling_Hash_Function.cpp b/Rolling_Hash_Function.cpp new file mode 100644 index 00000000..bc73a961 --- /dev/null +++ b/Rolling_Hash_Function.cpp @@ -0,0 +1,62 @@ +/* https://www.codechef.com/COOK118B/problems/CHEFSHIP +*/ + + +#include +using namespace std; + +#define ll long long + +ll p =31; +ll h[100001]; +ll power[100001]; + +ll mod = 1e9+7; + +// we will store hash value of strings till ith length in h[] array + +void generate_hash(string s) +{ + h[0] = s[0]-'a'+1; + power[0]=1; + for(int i=1;i>t; + while(t--) + { + string s; + cin>>s; + int n=s.length(); + int cnt =0; + generate_hash(s); + for(int i=1;i