From f1106366cd07803fae3fa431796db71bc1ad150d Mon Sep 17 00:00:00 2001 From: Abhijeet Kumar <49158711+abhijeetgu@users.noreply.github.com> Date: Wed, 21 Oct 2020 12:35:56 +0530 Subject: [PATCH] Create Rolling_Hash_Function.cpp --- Rolling_Hash_Function.cpp | 62 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Rolling_Hash_Function.cpp 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